Returns the index for the element with ID foo within another element. : index « jQuery « JavaScript DHTML






Returns the index for the element with ID foo within another element.

 
<html>
  <head>
    <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){

            alert($("*").index( $('#foo')[0] ));


        });
    </script>
  </head>
  <body>
    <body>
        <div id="foobar"><b></b><span id="foo"></span></div>

    </body>
</html>

   
  








Related examples in the same category

1.Get index among query
2.On click, returns the index (based zero) of that div in the page.
3.Returns the index for the element with ID foobar.
4.Returns -1, as there is no element with ID bar.
5.Use switch to check the clicked button