Saturday, November 20, 2010

Child (E > F)

Select all elements matched by F that are children of an element matched by E.

$('li > ul') selects all <ul> elements that are children of an <li> element
$('.myclass > code') selects all <code> elements that are children of an
element with the class myclass

As a CSS selector, the child combinator is supported by all modern web browsers
including Safari, Mozilla/Firefox, Opera, Chrome, and Internet Explorer 7 and
above but notably not by Internet Explorer versions 6 and below.

The child combinator (E > F) can be thought of as a more specific form of the
descendant combinator (E F) in that it selects only first-level descendants. Therefore,
in the following HTML code, the <img> element is a child only of the <span> element:


<div id="container">
<div id="inner">
<p>
<span><img src="example.jpg" alt="" /></span>
</p>
</div>
</div>

No comments:

Post a Comment