Child ('parent > child')S2C Home « Selectors « Child ('parent > child')

Child selector.

Shorthand version  $('parent > child')

Description

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

Syntax


Signature Description
jQuery('parent > child')Child match

Parameters


Parameter Description
parentA valid selector.
childA filter to select the direct child elements.

Return

N/A.

Child ('parent > child') Examplego to top of page Top

Selects all the specified direct child elements of the specified parent element.

The following example will select direct descendant 'em' elements with a parent 'p' element and change their background color to yellow.


$(function(){
  $('#btn7').on('click', function() {
    $('p > em').css('backgroundColor', 'yellow');
  });
}); 

Press the button below to action the above code:


go to home page Homepage go to top of page Top