Open In App
Related Articles

jQuery Selectors Complete Reference

Improve Article
Save Article
Like Article

jQuery selectors are used to select the HTML element(s) and allow you to manipulate the HTML element(s) in the way we want. It selects the HTML elements on a variable parameter such as their name, classes, id, types, attributes, attribute values, etc.



Example: In this example, we will select a class by using jQuery .class Selector.


<!DOCTYPE html>
    <script src=
        $(document).ready(function () {
            $(".GEEKS").css("background-color", "green");
    <p class="GEEKS">GeeksforGeeks</p>
    <span class="GEEKS">
        jQuery|.class selector



All the jQuery selectors are listed below:

jQuery Selectors



*Selects all the elements in the document, including HTML, body, and head. 
#idSpecifies an id for an element to be selected.
.classSpecifies the class for an element to be selected.
.class, .classselect multiple classes of an HTML document.
elementSelect and modify HTML elements based on the element name.
element1, element2Select multiple elements of an HTML document.
:firstSelect the first element of the specified type. 
:lastSelect the last element of the specified type.
:evenSelect an even number index from the elements.
:oddSelect an odd number index from the elements.
;first-childSelect every element that is the first child of its parent element.
:first-of-typeSelect all elements that are the first child, of a particular type, of their parent.
:last-childIt is a jQuery Selector used to select every element that is the last child of its parent. 
:last-of-typeSelect all elements which are the last child of their parent. 
:nth-child()Selects all elements that are the nth-child of their parent elements. 
:nth-last-child()Select all elements that are the nth last child of their parent.
:nth-of-type()Select all the nth-child elements of the specified parent.
:nth-last-of-type()Select all children of a parent with the same element name, counting from the last to the first. 
:only-childSelect every element that is the only child of its parent i.e only a single child is selected. 
:only-of-typeSelect all the elements that are the only child of their parent. 
parent > childSelect all elements that are the direct child of their parent element. 
parent descendantSelects every element which is descendant to a specific(parent) element. 
element + nextSelect the just “next” element of the specified “element”. 
element ~ siblingsSelect all elements that are siblings of the specified element. 
eq()It is used to locate the selected elements directly and returns an element with a specific index. 
:gt()Select all elements with an index greater than the index mentioned in the matched set. 
:lt()Selects elements using an index number that works on less than a specified number.
:not()Select all the elements which are not selected. 
:headerSelect all the heading elements that are from (<h1> to <h6>).
animatedSelect the element that is currently animated.
:focusselect all the elements that have focused on the document currently.
:contains()It is used to select elements containing the specified string. 
:has() Select all elements that have one or more elements inside of them, that match the specified selector.
:emptyIt is used to select empty elements.
:parentSelect all elements that are the parent of another element, including text nodes. 
:hiddenselects hidden elements to work upon. 
:visibleSelect all the elements that are currently visible in the document.
:root Select the root element of the HTML document. 
:lang()Select all the elements which have the lang attribute with the specified value.
[attribute] Select all the elements with the specified attribute.
[attribute!=value] Select each element that doesn’t have the specified attribute and value. 
[attribute$=value] Select each element with a specific attribute, with a specific ending string.
[attribute|=value] Select each element with a specific attribute, with a specific string value (like “geeks”).
[attribute^=value] Select all elements with the given attribute specified by the attribute parameter. 
[attribute~=value] Select all elements with a name attribute that contains the specific string. 
[attribute*=value]Select all elements with attributes specified by the attribute parameter.
:inputIt is used to select input elements. This selector is also used with a button element.
:textSelect an input element with a text field i.e (type==text). 
:passwordSelect the input element having a password field. i.e (type==password)
:radioSelect all elements of type radio. 
:checkbox Selects input elements with type=checkbox.
:submit Select the submit button and input the element having the submitted type field.
:resetSelect the input element having a reset field button.i.e <input type=”button”>. 
:button Selects button elements and input elements with type=”button”. 
:imageSelect the input elements with a type equal to the image
:fileSelects the input element having a file field.(type==file) 
:enabledSelect all enabled form elements. 
:disabled Selecting all disabled form elements. 
:selected Select option elements that are pre-selected. 
:checked Checked checkboxes, radio buttons, and options of select elements.

Last Updated : 29 Jun, 2023
Like Article
Save Article
Similar Reads
Related Tutorials