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 |
How to check data type of any variable in jquery? : jquery mobile
What is jquery toggle function?
explain width() vs css(‘width’) in jquery
Explain the difference between parent() and parents() methods in jquery? : jquery mobile
Which one is more efficient, document.getElementbyId( "myId") or $("#myId)?
Which one is more efficient, document.getelementbyid( "idname") or $("#idname)?
Can we use our own specific character in the place of $ sign in jQuery?
What is .remove()? : jquery mobile
How does jquery mobile theming work? : jquery mobile
what are the features of jquery
What is .detach()? : jquery mobile
What is the basic need to start with jQuery?