Javascript examples for jQuery Method and Property:index
The element can be specified using a DOM element, or a jQuery selector.
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ console.log($(".hot").index($("#myId"))); });/* w w w. j a v a 2 s . c om*/ }); </script> </head> <body> <button>Get index</button> <ul> <li>A</li> <li class="hot">B</li> <li class="hot" id="myId">C</li> </ul> </body> </html>