Answer Posted / 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 |
Post New Answer View All Answers
Have any of your startup projects failed dismally - if so, why and how did you learn from them?
Explain width() vs css(‘width’)?
Differentiate between jquery.size and jquery.length? : jQuery Mobile
What is the minimum setup needed to start using jquery.
What is jquery mobile theming? : jquery mobile
Define jquery filter?
What is jquery.noconflict? Explain
Explain the use of the .pushstack() method.
How can we apply css in even childs of parent node using jquery library?
Tell me what are the slow selectors in jquery? : jquery mobile
Is jquery a framework?
How to programmatically trigger a click event thats being handled by jquery only?
What is jquery connect and how to use it?
How can related code be encapsulated? Give example.
What are the methods used to provide effects in jquery?