How to use Misc Each() Method in JQuery

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

jQuery Misc Each() Method

jquery Misc Each() method use for defined a function that will run for each match element.

Syntax

$(selectElement).each(function(index,element))

 

Example // In this example when we click on button then slideUp() method will apply on each <p>  element.
 

<html>

<head>

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

    <script type="text/javascript">

        $(document).ready(function () {

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

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

                    $(this).slideUp()

                });

            });

        });

    </script>

</head>

<body>

    <button>

        click me</button>

    <p>

        prabhakar</p>

    <p>

        Ajay</p>

    <p>

        Abhishek</p>

</body>

</html>

Output

each.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
 
© 2020 DotNetHeaven. All rights reserved.