📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials jQuery in Practice Chaining

Chaining

4 min read
Most jQuery methods return the same jQuery object for chaining: $('.items').addClass('active').css('color', 'blue').fadeIn(). end() returns to the previous jQuery object after a traversal.

Method Chaining

jQuery methods return the jQuery object, enabling chains:

$('#box')
  .css('background', 'red')
  .addClass('active')
  .fadeIn(500)
  .delay(1000)
  .fadeOut(500);

// Conditional chain with .end()
$('ul').find('li.active').css('color', 'red').end()
        .find('li.done').css('color', 'green');