Selecting elements

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

Selects all elements.

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

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

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

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

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

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

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

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

Selects all button elements and elements of type button.

Selects all elements of type checkbox.

Matches all elements that are checked or selected.

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

Selects all elements with the given class.

Select all elements that contain the specified text.

Selects all elements that are descendants of a given ancestor.

Selects all elements that are disabled.

Selects all elements with the given tag name.

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

Selects all elements that are enabled.

Select the element at index n within the matched set.

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

Selects all elements of type file.

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

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

Selects the first matched DOM element.

Selects element if it is currently focused.

Select all elements at an index greater than index within the matched set.

Selects elements that have the specified attribute, with any value.

Selects elements which contain at least one element that matches the specified selector.

Selects all elements that are headers, like h1, h2, h3 and so on.

Selects all elements that are hidden.

Selects a single element with the given id attribute.

Selects all elements of type image.

Selects all input, textarea, select and button elements.

Selects all elements of the specified language.

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

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

Selects the last matched element.

Select all elements at an index less than index within the matched set.

Matches elements that match all of the specified attribute filters.

Selects the combined results of all the specified selectors.

Selects all next elements matching “next” that are immediately preceded by a sibling “prev”.

Selects all sibling elements that follow after the “prev” element, have the same parent, and match the filtering “siblings” selector.

Selects all elements that do not match the given selector.

Selects all elements that are the nth-child of their parent.

Selects all elements that are the nth-child of their parent, counting from the last element to the first.

Selects all the elements that are the nth-child of their parent in relation to siblings with the same element name, counting from the last element to the first.

Selects all elements that are the nth child of their parent in relation to siblings with the same element name.

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

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

Selects all elements that have no siblings with the same element name.

Select all elements that have at least one child node (either an element or text).

Selects all elements of type password.

Selects all elements of type radio

Selects all elements of type reset.

Selects the element that is the root of the document.

Selects all elements that are selected.

Selects all elements of type submit.

Selects the target element indicated by the fragment identifier of the document’s URI.

Selects all input elements of type text.

Selects all elements that are visible.

Last updated