09.02.2015 Views

DOM Traversal Methods - MarkMail

DOM Traversal Methods - MarkMail

DOM Traversal Methods - MarkMail

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Chapter 2<br />

As always, remember that development time is typically the most valuable resource.<br />

Do not focus on optimization of selector speed unless it is clear that performance<br />

needs to be improved.<br />

As a CSS selector, the multiple-class syntax of example 3 is supported by all modern<br />

web browsers, but not by Internet Explorer versions 6 and below, which makes the<br />

syntax especially handy for applying styles cross-browser through jQuery.<br />

Descendant: E F<br />

All elements matched by F that are descendants of an element matched by E.<br />

Examples<br />

1. $('#container p'): selects all elements matched by that are<br />

descendants of an element that has an id of container<br />

2. $('a img'): selects all elements matched by that are descendants of an<br />

element matched by <br />

Description<br />

A descendant of an element could be a child, grandchild, great-grandchild,<br />

and so on, of that element. For example, in the following HTML, the <br />

element is a descendant of the , , , and<br />

elements:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Child: E > F<br />

All elements matched by F that are children of an element matched by E.<br />

Examples<br />

1. $('li > ul'): selects all elements matched by that are children of an<br />

element matched by <br />

2. $('p > code'): selects all elements matched by that are children of an<br />

element matched by <br />

[ 19 ]

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

Saved successfully!

Ooh no, something went wrong!