>>> $("body span");
[ span, span.foo ]
Selecting Child Elements
Child elements are a more-specific style of descendant selector. Only the very next level of element is
considered for matching. To select a child element, use the parent element followed by a greater than (>)
symbol, followed by the child element to match:
parent>child
In your test file, try to select any spans that are child elements of the body element by entering the
following command in the console:
$("body>span");
Because there are no spans directly contained within the body element, the console will output the
following:
>>> $("body>span");
[ ]
Next, filter all span elements that are direct children of a paragraph element:
$("p>span");
The resulting output looks like this:
>>> $("p>span");
Do'stlaringiz bilan baham: |