what is the chaining in Jquery ?(Part 6)


Chaining is the ways to chain the method one after other method in the single function.
It is one of very important concepts in Jquery. Using chaining, we can write multiple Jquery methods with in the single statement.

Note: Most Jquery methods are chainable but not all.

Now let see one of the basic example of chaining in Jquery

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="../../Scripts/jquery.min.js"></script>
    <script>
        $(function () {
            $("#Chain").click(function () {
                $("p").css({ "background-color": "green", "height": "300px", "width": "300px" })
                      .slideUp(3000).slideDown(3000)
                      .animate({ left: '350px' }, 5000)
                      .animate({ top: '350px' }, 5000)
                      .animate({ left: 0 }, 5000)
                      .animate({ top: 0 }, 5000);
            });
        });
    </script>
</head>
<body>
     <button id="Chain">Click here</button>
     <br />

    <p style="position:absolute;">
        Try to animate me.
    </p>
</body>
</html>

Summary
In the above example we showed that the basic example chaining in Jquery.

Advertisements
Posted in Jquery. 1 Comment »

One Response to “what is the chaining in Jquery ?(Part 6)”

  1. Learn Jquery with in 15 hrs | Chandradev's Blog Says:

    […] 6. what is the chaining in Jquery ?(Part 6) […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: