Appendix B. Selectors Supported by jQuery

The following table contains the selector syntax that you are able to use with jQuery's Selector API:

Selector

Description

Simple Selectors

#id

Selects a single element via the ID name specified in the element's id attribute.

element

Selects one or more elements by the element name, for example, form, div, input, and so on.

.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.

grouping, multiple, selectors

Selects one or more elements by chaining multiple selectors together with commas.

Hierarchy

ancestor descendent

Selects one or more elements based on an ancestral relationship.

parent > child

Selects one or more elements based on a parent, child relationship.

sibling + nextAdjacentSibling

Selects the sibling immediately following an element.

sibling ~ anyProceedingSibling

Selects any siblings immediately following an element.

Basic Filters

:first

Selects the first element.

:last

Selects the last element.

:not(selector)

Selects elements based on what you don't want.

:even

Selects only elements falling within even numbering. Since jQuery calculates position offset from zero, this actually results in the odd-numbered items being returned. Item one would be considered number zero, item two would be considered number one, and so on; so even matches numbers zero, two, four, and so on.

:odd

Selects only elements falling ...

Get Beginning JavaScript® and CSS 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.