02.06.2013 Views

DOM Traversal Methods

DOM Traversal Methods

DOM Traversal Methods

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Selector Expressions<br />

Description<br />

As a CSS selector, the child combinator is supported by all modern web browsers<br />

including Safari, Mozilla/Firefox, and Internet Explorer 7, but notably not by<br />

Internet Explorer versions 6 and below. Example 1 is a handy way to select all nested<br />

unordered lists (i.e. excepting the top level).<br />

The child combinator can be thought of as a more specific form of the (single-space)<br />

descendant combinator in that it selects only first-level descendants. Therefore, in the<br />

following HTML, the element is a child only of the element.<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Adjacent Sibling: E + F<br />

All elements matched by F that immediately follow, and have the same parent as, an<br />

element matched by E.<br />

Examples<br />

1. $('ul + p'): selects all elements by (paragraph) that immediately follow<br />

a sibling element matched by (unordered list)<br />

2. $('strong + em'): selects all elements matched by that immediately<br />

follow a sibling element matched by <br />

Description<br />

One important point to consider with both the + combinator and the ~ combinator<br />

(covered next) is that they only select siblings. Consider the following HTML:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

[ 20 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!