jQuery Selectors

In jquery, selectors are used to select and manupulate the elements in the HTML Document.

Syntax $("h1")
By selecting it selects all the h1 tags in the HTML Document and can manupulate them.

Use of selectors in jQuery

Here are the selector types and its syntax in jQuery

Selector Type



Element Selector


Selects all elements of a specific type (e.g., <p>).

ID Selector


Selects a single element by its ID attribute.

Class Selector


Selects all elements with a specific class.

Attribute Selector


Selects elements based on the presence or value of attributes.

Descendant Selector

$("div p")

Selects all elements that are descendants of a specified element.

Child Selector

$("ul > li")

Selects all direct children of a specified element.

Sibling Selector

$("h2 + p")

Selects all elements that are siblings of a specified element.

:first Selector


Selects the first matched element.

:last Selector


Selects the last matched element.

:even Selector


Selects even elements.

:odd Selector


Selects odd elements.

Quick Recap - Topics Covered

jQuery Selectors

Practice With Examples in Compilers

The Concepts and codes you leart practice in Compilers till you are confident of doing on your own. A Various methods of examples, concepts, codes availble in our websites. Don't know where to start Down some code examples are given for this page topic use the code and compiler.

Example 1
Example 1 Example 2 Example 3 Example 4 Example 5