How to use Misc Index() Method in JQuery

In this article I am going to explain about misc index() method in jquery.
  • 1710

jQuery Misc Index() Method

jquery index() Method use for return the index number of selected element. If any element have no any index number then it will return -1.

Syntax

$(selector).index()

Example

<html>

<head>

    <script type="text/javascript" src="jquery.js"></script>

    <script type="text/javascript">

        $(document).ready(function () {

            $("p").click(function () {

                alert($(this).index());

            });

        });

    </script>

</head>

<body>

    <p style="color: Blue">

        Click for get index number</p>

    <p>

        prabhakar</p>

    <p>

        Arjun</p>

    <p>

        Vikash</p>

</body>

</html>

 

Output


indexno.jpg


indexno2.jpg

 

You may also want to read these related articles: here
 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 
© 2019 DotNetHeaven. All rights reserved.