JQuery Array Index

 

In this Example The index() method returns the index position of specified elements relative to other specified elements  and click the list items to get the index position, relative to its sibling elements

 
 
 
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script> <script> $(document).ready(function(){ $("li").click(function(){ alert($(this).index()); }); }); </script> </head> <body> <h1 style="color: purple">Select any one in list </h1> <ul> <li>Appwrk Dot Net Team</li> <li>Appwrk Design Team</li> <li>Appwrk Management Team</li> <li>Appwrk PHP Team</li> <li>Appwrk Angular Team</li> </ul> </body> </html>
Output