This article mainly shares with you an example of jQuery triggering a click event by default on the first run page. It has a good reference value and I hope it will be helpful to everyone. Let’s follow the editor to take a look, I hope it can help everyone.
For example:
1. $("#txt").trigger("click");//The default trigger is to click the search button
2. $ (".aaa .bbb").eq(0).click();//default first click (for example, UL's LI has multiple clickable ones for the default click first)
Note:
should be placed outside the function, otherwise it will not work
Related recommendations:
jQuery ajax dynamically adding nodes cannot trigger clicks How to solve the event
JQuery simulates a click event and automatically triggers the event
How the click event triggers the content change of the span element
The above is the detailed content of The click event is triggered by default when jQuery is run for the first time.. For more information, please follow other related articles on the PHP Chinese website!