• jQuery
  • jQuery UI
  • jQuery Mobile
  • Sizzle
  • QUnit
  • Plugins
  • Contribute
    • CLA
    • Style Guides
    • Bug Triage
    • Code
    • Documentation
    • Web Sites
  • Events
  • Support
    • Learning Center
    • Chat
    • Stack Overflow
    • Report a bug
  • OpenJS Foundation
    • Join
    • Members
    • jQuery Team
    • Governance
    • Conduct
    • Projects

jQuery API Documentation

  • Download
  • API Documentation
  • Blog
  • Plugins
  • Browser Support
  • Version Support

Category: Selectors


Borrowing from CSS 1–3, and then adding its own, jQuery offers a powerful set of tools for matching a set of elements in a document.

To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[\]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\. For example, an element with id="foo.bar", can use the selector $("#foo\\.bar"). The W3C CSS specification contains the complete set of rules regarding valid CSS selectors. Also useful is the blog entry by Mathias Bynens on CSS character escape sequences for identifiers.

Also in: Selectors > Basic

All Selector (“*”)

Selects all elements.

Also in: Selectors > Basic Filter | Selectors > jQuery Extensions

:animated Selector

Select all elements that are in the progress of an animation at the time the selector is run.

Also in: Selectors > Attribute

Attribute Contains Prefix Selector [name|=”value”]

Selects elements that have the specified attribute with a value either equal to a given string or starting with that string followed by a hyphen (-).

Also in: Selectors > Attribute

Attribute Contains Selector [name*=”value”]

Selects elements that have the specified attribute with a value containing a given substring.

Also in: Selectors > Attribute

Attribute Contains Word Selector [name~=”value”]

Selects elements that have the specified attribute with a value containing a given word, delimited by spaces.

Also in: Selectors > Attribute

Attribute Ends With Selector [name$=”value”]

Selects elements that have the specified attribute with a value ending exactly with a given string. The comparison is case sensitive.

Also in: Selectors > Attribute

Attribute Equals Selector [name=”value”]

Selects elements that have the specified attribute with a value exactly equal to a certain value.

Also in: Selectors > Attribute | Selectors > jQuery Extensions

Attribute Not Equal Selector [name!=”value”]

Select elements that either don’t have the specified attribute, or do have the specified attribute but not with a certain value.

Also in: Selectors > Attribute

Attribute Starts With Selector [name^=”value”]

Selects elements that have the specified attribute with a value beginning exactly with a given string.

Also in: Selectors > Form | Selectors > jQuery Extensions

:button Selector

Selects all button elements and elements of type button.

Also in: Selectors > Form | Selectors > jQuery Extensions

:checkbox Selector

Selects all elements of type checkbox.

Also in: Selectors > Form

:checked Selector

Matches all elements that are checked or selected.

Also in: Selectors > Hierarchy

Child Selector (“parent > child”)

Selects all direct child elements specified by “child” of elements specified by “parent”.

Also in: Selectors > Basic

Class Selector (“.class”)

Selects all elements with the given class.

Also in: Selectors > Content Filter | Selectors > jQuery Extensions

:contains() Selector

Select all elements that contain the specified text.

Also in: Selectors > Hierarchy

Descendant Selector (“ancestor descendant”)

Selects all elements that are descendants of a given ancestor.

Also in: Selectors > Form

:disabled Selector

Selects all elements that are disabled.

Also in: Selectors > Basic

Element Selector (“element”)

Selects all elements with the given tag name.

Also in: Selectors > Content Filter

:empty Selector

Select all elements that have no children (including text nodes).

Also in: Selectors > Form

:enabled Selector

Selects all elements that are enabled.

Also in: Selectors > Basic Filter | Deprecated > Deprecated 3.4 | Selectors > jQuery Extensions

:eq() Selector

Select the element at index n within the matched set.

Also in: Selectors > Basic Filter | Deprecated > Deprecated 3.4 | Selectors > jQuery Extensions

:even Selector

Selects even elements, zero-indexed. See also :odd.

Also in: Selectors > Form | Selectors > jQuery Extensions

:file Selector

Selects all elements of type file.

Also in: Selectors > Child Filter

:first-child Selector

Selects all elements that are the first child of their parent.

Also in: Selectors > Child Filter

:first-of-type Selector

Selects all elements that are the first among siblings of the same element name.

Also in: Selectors > Basic Filter | Deprecated > Deprecated 3.4 | Selectors > jQuery Extensions

:first Selector

Selects the first matched DOM element.

Also in: Selectors > Basic Filter | Selectors > Form

:focus Selector

Selects element if it is currently focused.