Selectors Reference

The jQuery Selectors are used to “find” (or select) HTML elements based on their name, id, classes, types, attributes, values, etc. jQuery provides set of selectors, including basic selectors, attribute selectors, etc.

These selectors simplifies the process of identifying and interacting with specific elements, reducing the complexity of JavaScript code.

jQuery Selectors Reference

In the following table, we have listed all the jQuery Selectors −

Sr.No.Methods & Description
1*Selects all elements.
2#idSelects an element with the specified id.
3.classSelects all elements with the specified class.
4.class,.classSelects all elements with any of the specified classes.
5elementSelects all elements with the specified tag name.
6el1,el2,el3Selects all elements with any of the specified tag names.
7:firstSelects the first element in the set of matched elements.
8:lastSelects the last element in the set of matched elements.
9:evenSelects even elements (based on zero-index).
10:oddSelects odd elements (based on zero-index).
11:first-childSelects every element that is the first child of its parent.
12:first-of-typeSelects every element that is the first of its type among its siblings.
13:last-childSelects every element that is the last child of its parent.
14:last-of-typeSelects every element that is the last of its type among its siblings.
15:nth-child(n)Selects every element that is the nth child of its parent.
16:nth-last-child(n)Selects every element that is the nth child of its parent, counting from the last child.
17:nth-of-type(n)Selects every element that is the nth of its type among its siblings.
18:nth-last-of-type(n)Selects every element that is the nth of its type among its siblings, counting from the last.
19:only-childSelects every element that is the only child of its parent.
20:only-of-typeSelects every element that is the only one of its type among its siblings.
21parent > childSelects all child elements that are a direct child of the parent.
22parent descendantSelects all descendant elements that are a descendant of the parent.
23element + nextSelects the next element that is immediately preceded by the element.
24element ~ siblingsSelects all siblings elements that are preceded by the element.
25:eq(index)Selects the element with the specified index.
26:gt(no)Selects all elements with an index greater than the specified number.
27:lt(no)Selects all elements with an index less than the specified number.
28:not(selector)Selects all elements that do not match the given selector.
29:headerSelects all header elements (<h1> to <h6&g;).
30:animatedSelects all elements that are currently being animated.
31:focusSelects the element that currently has focus.
32:contains(text)Selects all elements that contain the specified text.
33:has(selector)Selects all elements that have at least one element matching the specified selector as a descendant.
34:emptySelects all elements that have no children (including text nodes).
35:parentSelects all elements that have at least one child node (either an element or text).
36:hiddenSelects all elements that are hidden.
37:visibleSelects all elements that are visible.
38:rootSelects the document’s root element.
39:lang(language)Selects all elements with the specified language attribute.
40[attribute]Selects all elements with the specified attribute.
41[attribute=value]Selects all elements with the specified attribute and value.
42[attribute!=value]Selects all elements with the specified attribute and not the specified value.
43[attribute$=value]Selects all elements with the specified attribute ending with the specified value.
44[attribute|=value]Selects all elements with an attribute value that either exactly matches the specified value or starts with the specified value followed by a hyphen (-).
45[attribute^=value]Selects all elements with the specified attribute beginning with the specified value.
46[attribute~=value]Selects all elements with the specified attribute containing the specified value (space-separated list).
47[attribute*=value]Selects all elements with the specified attribute containing the specified value.
48:inputSelects all input, textarea, select, and button elements.
49:textSelects all input elements with type “text”.
50:passwordSelects all input elements with type “password”.
51:radioSelects all input elements with type “radio”.
52:checkboxSelects all input elements with type “checkbox”.
53:submitSelects all input elements with type “submit”.
54:resetSelects all input elements with type “reset”.
55:buttonSelects all button elements and input elements with type “button”.
56:imageSelects all input elements with type “image”.
57:fileSelects all input elements with type “file”.
58:enabledSelects all enabled elements.
59:disabledSelects all disabled elements.
60:selectedSelects all selected options in a dropdown.
61:checkedSelects all checked checkboxes or radio buttons.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *