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.

You got me lookin' up high<br />

You got me searchin' down low<br />

—Devo,<br />

"Jerkin' Back 'n' Forth"<br />

Selector Expressions<br />

Borrowing from CSS 1–3 and basic XPath, and then adding its own, jQuery offers a<br />

powerful set of selector expressions for matching a set of elements in a document. In<br />

this chapter, we'll examine every selector expression that jQuery makes available<br />

in turn.<br />

CSS Selectors<br />

The following selectors are based on the CSS 1–3, as outlined by the W3C. For more<br />

information about the specifications, visit http://www.w3.org/Style/CSS/#specs.<br />

Element: T<br />

All elements that have a tag name of T.<br />

Example<br />

1. $('div'): selects all elements with a tag name of div in the document<br />

2. $('em'): selects all elements with a tag name of em in the document<br />

Description<br />

jQuery uses JavaScript's getElementsByTagName() function for tag-name selectors.<br />

ID: #myid<br />

The unique element with an ID equal to myid.

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

Saved successfully!

Ooh no, something went wrong!