• jQuery Method Chaining

    jQuery Method Chaining

    In jQuery Method Chaining, there is a technique called chaining, that allows us to run multiple jQuery commands, one after the other, on the same element(s). This way, browsers do not have to find the same element(s) more than once.

    To chain an action, you simply append the action to the previous action. The following example chains together the css(), slideUp(), and slideDown() methods. The “div1” element first change to red, then it slides up, and then it slides down:

    Example:

    $(“#div1).css(“color,”red”).slideUp(2000).slideDown(2000);

    This also works just fine:

     $(“#div1).css(“color,”red”)

      .slideUp(2000)

      .slideDown(2000);

    Appreciate my work :Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPin on PinterestShare on RedditShare on StumbleUponShare on TumblrDigg thisShare on YummlyShare on VKFlattr the authorBuffer this page

Leave a Reply

Your email address will not be published. Required fields are marked *