List of all jQuery Selectors

The following table shows the various types of selectors available in jQuery:

Selectors Syntax Description
ID selector $(“#id-name”) Specifies an id for an element to be selected.
Class selector $(“.class-name”) Specifies the class for an element to be selected.
Tag name selector $(“element-name”) Select and modify HTML elements based on the element name.
* $(“*”) It is used to select all elements.
.Class, .Class $(“.name1, .name2) It selects all elements with class name1 and name2.
:first $(“p:first”) It is used to select the first <p> element.
:last $(“p:last”) It is used to select the last <p> element.
:first-child $(“p:first-child”) It is used to select all <p> elements that are the first child of their parent.
:last-child $(“p:last-child”) It is used to select all <p> elements that are the last child of their parent.
only-child $(“p:only-child”) It is used to select all <p> elements that are the only child of their parent.
:only-of-type $(“p:only-of-type”) It is used to select all <p> elements that are the only child of its type of their parent.
:header $(“:header”) It is used to select all header elements.
:hidden $(“p:hidden”) It is used to select all hidden <p> element.
::animated $(“:animated”) It is used to select all animated elements.
:root $(“:root”) It is used to select the document’s root element.
:focus $(“:focus”) It is used to select an element if it is is currently focused.
:has(selector) $(“:has(p)”) It is used to select All div elements are selected that have a p element.
:empty $(“:empty”) The empty elements are selected.
[attribute] $(“[href]”) All elements with a href attribute are selected.
[attribute=value] $(“[href=’gfg.css’]”) All elements with a href attribute value equal to gfg.css are selected.
[attribute^=value] $(“[title^=’Hardy’]”) All elements with a title attribute value starting with “Hardy” are selected.
[attribute~=value] $(“[title~=’Good’]”) All elements with a title attribute value containing the specific value “Good” are selected.
[attribute*=value] $(“[title*=’Good’]”) All elements with a title attribute value containing the word “Good” are selected.
:Input $(“:input”) All input elements are selected.
:radio $(“:radio”) All input elements with type=”radio” are selected.
:password $(“:password”) All input elements with type=”password” are selected.
:text $(“:text”) All input elements with type=”text” are selected.
:checkbox $(“:checkbox”) All input elements with type=”checkbox” are selected.
:submit $(“:submit”) All input elements with type=”submit” are selected.
:reset $(“:reset”) All input elements with type=”reset” are selected.
:file $(“:file”) All input elements with type=”file” are selected.
:button $(“:button”) All input elements with type=”button” are selected.
:image $(“:image”) All input elements with type=”image” are selected.
:disabled $(“:disabled”) All disabled input elements are selected.
:enabled $(“:enabled”) All enabled input elements are selected.
:checked $(“:checked”) All checked input elements are selected.
:selected $(“:selected”) All selected input elements are selected.
parent descendant $(“parent descendant”) It is used to select all <p> elements that are descendants of a <div> element.
element + next $(“element + next”) The <p> elements that are next to each <div> elementis selected.
element ~ siblings $(“element ~ sibling”) All <p> elements that are siblings of a <div> elements are selected.
:eq(index) $(“ul li:eq(1)”) It will select the second element in a list (index starts at 0).
:gt(no) $(“ul li:gt(3)”) The list elements with an index greater than 3 are selected.
:lt(no) $(“ul li:lt(2)”) The list elements with an index less than 2 are selected.
:not(selector) $(“input:not(:empty)”) All input elements that are not empty are selected.
:even $(“tr:even”) it will select all even tr elements
:odd $(“tr:odd”) it will select all odd tr elements.


JQuery Selectors

Similar Reads

What is a jQuery Selector?

jQuery selectors are functions that allow you to target and select HTML elements in the DOM based on element names, IDs, classes, attributes, and more, facilitating manipulation and interaction....

jQuery #id Selector

jQuery #id selector allows you to target specific elements by their unique ID attribute using the # symbol followed by the ID name....

jQuery .Class Selector

...

jQuery Tag Name Selector

In jQuery, a class selector is used to target HTML elements by their class attribute using the dot ( . ) symbol followed by the class name....

List of all jQuery Selectors

...