Class ('ancestor descendant') JQ Home  <<  Selectors  <<  Descendant ('ancestor descendant')

Descendant selector.

Shorthand version $('ancestor descendant')

Description

The ('ancestor descendant') selector, selects all specified descendant elements of the specified ancestor 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') Example Selectors  <<  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:

Related Tutorials

jQuery Basic Tutorials - Lesson 3 - CSS Selectors