What is chaining in jQuery?

devquora
devquora

Posted On: Feb 22, 2018

 

Chaining in jQuery lets you run multiple statements one after another on the same element. To chain multiple commands, append each jQuery command to the previous one using dot(.). Chaining allows you not to use one selector more than once for performing an action as all the actions are performed at once. It speeds up the time taken to execute the code as the compiler need not call a selector more than one time.

Example

$(“#h1”).css(“color”, "blue”).slideUp(200).slideDown(100); 

In the above statement, the color, slideup, and slidedown action are applied on the heading selector in the same line using chaining.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    jQuery Interview Questions

    What is jQuery?

    jQuery is a lightweight JavaScript library which gives a quick and simple method for HTML DOM traversing and manipulati..

    jQuery Interview Questions

    What are the advantages of JQuery ?

    There are many advantages of JQuery. Some of them are :It is more like a JavaScript enhancement so there is no overhea..

    jQuery Interview Questions

    What are the different type of selectors in Jquery?

    There are 3 types of selectors in JqueryCSS Selector XPath Selector Custom Selector..