jquery Determines if the current element is the first element & gets the nth elementLet's say that you have the following HTML code:
<ul> <li>jquery Judging the current element is the first few elements example </li> <li>jquery Gets the nth element example </li> <li >jquery Selector Example </li></ul>
jquery determines that the current element is the first element
If we click on any of the LI tags and want to know the number of Li tags that are currently clicked, you can use the following code:
$ ("ul Li"). Click (function () { var index = $ ("ul Li"). index (this); alert (index); });
JQuery gets the nth element
Similarly, if we want to get the second Li tag element, you can use the following code
var element=$ ("ul li"). EQ (1); alert (Element). HTML ());
jquery determines if the current element is the first element & gets the nth element