jQuery parent > childSelector

jQuery 选择器jQuery Selector

Examples

Select <span> elements that are direct children of a <div> element:

$("div > span")

Try it Yourself »

Definition and Usage

The ("parent > child") selector selects all elements that are direct children of the specified parent element.


Syntax

("parent > child")

Parameter Description
parent Required. Specifies the parent element to select.
child Required. Specifies the direct child element to select (belonging to the specified parent element).


实例

Try it Yourself - Examples

Select all <li> elements that are direct children of a <ul> element
How to select all <li> elements that are direct children of a <ul> element with classname.


jQuery 选择器jQuery Selector

Other Extensions