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

Descendant selector.

Shorthand version  $('ancestor descendant')

Description

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

Syntax


Signature Description
jQuery('ancestor descendant')Descendant match

Parameters


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

Return

N/A.

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.


$(function(){
  $('#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