What is chaining in jQuery?
Answer / chaitanya
Chaining is one of the most powerful feature of jQuery. In jQuery, Chaining means to connect multiple functions, events on selectors. It makes your code short and easy to manage and it gives better performance. The chain starts from left to right. So left most will be called first and so on.
Hide Copy Code
$(document).ready(function(){
$('#dvContent').addClass('dummy');
$('#dvContent').css('color', 'red');
$('#dvContent').fadeIn('slow');
});
The above jQuery code sample can be re-written using chaining. See below.
Hide Copy Code
$(document).ready(function(){
$('#dvContent').addClass('dummy')
.css('color', 'red')
.fadeIn('slow');
});
Not only functions or methods, chaining also works with events in jQuery. Find out more here.
| Is This Answer Correct ? | 0 Yes | 0 No |
Can you use any other name in place of $ (dollar sign) in jQuery?
In what scenarios jQuery can be used?
What the use of $ symbol in jquery.
What are the different ways of using $.connect function in jquery?
Explain various methods to make ajax request in jquery?
How does caching helps and how to use caching in jQuery?
How to get the server response from an ajax request using jquery?
What is jquery.size()? : jquery mobile
What are the differences between size and length in jquery?
Explain the difference between find and children methods in jquery?
What is the method used to define the specific character in place of $ sign?
What are the types of selectors that are used in jquery? Give examples.