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 |
Tell me which program is useful for testing jquery?
Difference between detach and remove? : jQuery Mobile
Is it too early to discuss jquery ui 1.8?
Explain some of the key concepts of good code organization patterns.
How do I pull a native DOM element from a jQuery object?
How to use jquery?
Why use jQuery filter() Methods?
How do you select an item using css class or id and get the value by use of jquery.
Do we need to add the jquery file both at the master page and content page as well?
How to create clone of any object using jQuery?
How can related code be encapsulated? Give example.
Explain the concepts of "$ function" in jquery with an example?