Appendix B

jQuery Selectors

The following table contains the selector syntax that you can use with jQuery's Selector API, which is implemented using the open source Sizzle engine.

Selector Description
Simple SelectorsThe following selectors are the most basic, commonly used selectors.
#idNamediv#idName Selects a single element via the id name specified in the element's id attribute.
div Selects one or more elements by the element name—for example, form, div, input, and so on.
div.className.className Selects one or more elements via a class name present in the element's class attribute. Individual elements may also have multiple class names.
* The universal or wildcard selector; selects all elements.
div.body, div.sideColumn, h1.title Selects one or more elements by chaining multiple selectors together with commas.
HierarchyThe following selectors are used based on hierarchical context.
div.outerContainer table.form Selects one or more elements based on an ancestral relationship.
div#wrapper > h1.title Selects one or more elements based on a parent, child relationship.
h3 + p Selects the sibling immediately following an element.
h3 ∼ p Selects any siblings immediately following an element.
Context FiltersThe following selectors are applied based on the context elements that appear in the document.
:root Selects the root element of the document; in an HTML document this will be the <html> element. In an XML document, it will be whatever name is given ...

Get Web Development with jQuery now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.