1.

What Is Chaining In Jquery?

Answer»
  • Chaining is very POWERFUL feature of jQuery.
  • Chaining means specifying multiple FUNCTION and/or selectors to an element.
  • Examine the below example
$(DOCUMENT).ready(function(){ $('#mydiv').CSS('color', 'blue'); $('#mydiv').addClass('myclass'); $('#mydiv').fadeIn('fast'); }

By using chaining we can write above code as follows

$(document).ready(function(){ $('#mydiv').css('color','blue').addClass('myclass').fadeIn('fast'); });
  • Advantage of chaining is that it makes your code simple and simple to manage.
  • The execution becomes faster because the code search for the element only once.

 

By using chaining we can write above code as follows

 



Discussion

No Comment Found