Descendant ('ancestor descendant')S2C Home « Selectors « Descendant ('ancestor descendant')

Descendant selector.

Shorthand version  $('ancestor descendant')


The ('ancestor descendant') selector, selects all the specified direct child elements of the specified parent element.


Signature Description
jQuery('ancestor descendant')Descendant match


Parameter Description
ancestorA valid selector.
descendantA filter to select the descendant.



Descendant ('ancestor descendant') Examplego to top of page Top

Selects all specified descendant elements of the specified ancestor element.

The following example will select all 'td' descendants of 'tr' elements and change the background color of these elements to yellow.

  $('#btn9').on('click', function() {
    $('tr td').css('backgroundColor', 'yellow');

Press the button below to action the above code:

go to home page Homepage go to top of page Top