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">
    <script src="../../Scripts/jquery.min.js"></script>
        $(function () {
            $("#Chain").click(function () {
                $("p").css({ "background-color": "green", "height": "300px", "width": "300px" })
                      .animate({ left: '350px' }, 5000)
                      .animate({ top: '350px' }, 5000)
                      .animate({ left: 0 }, 5000)
                      .animate({ top: 0 }, 5000);
     <button id="Chain">Click here</button>
     <br />

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

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


One thought on “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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.