JQuery simulates clicking on the A tag example reference


I puzzled over the question for half an hour, and then I thought it was so.

The menu


<li class="menu"><a href="xxx.com" target="_blank"></a></li>

Click < Li> When the inner hyperconnection is triggered:


//The right choice
$("li.menu").children("a")[0].click()
//The following is not possible
$("li.menu").children("a").eq(0).click()

- says parameter error, no bound click event function found,

Because eq(0) returns a jQuery object, when click() happens, it looks for a function bound to it, but it doesn’t bind to a function at all, so it has an error.

, [0] returns a DOM object, and when click() occurs, the original behavior of the element is executed.

Note :[0] is the same thing as get(0).