When you use the JavaScript then read and modify the content of the page is the very common task. While doing this you want to find the elements that you wish to change and for this work selector is used in jQuery. When you use the normal JavaScript, finding elements become extremely complicated, unless you need to find a single element which has a value specified in the ID attribute.

Using the jQuery selector you can find the elements based on their attribute, types, name, id, classes, values of attributes and much more.

jQuery selectors is most important part of the jQuery library. jQuery selectors provide the facility to select and manipulate HTML element (s).

In jQuery all the selectors start with the dollar sign and parentheses: $()

A jQuery statement typically follows the syntax pattern:

$(selector).methodName ();

Using elements, ID’s, classes and attribute

Here are some common ways of selecting the elements on a page.

The #id selector

The #id selector of jQuery is used to find the specific element through the id attribute of an HTML tag.

When you want a single element with the unique ID on the page, you can use the ID selector.



Try Now

The .class selector

The class selector is used to find the elements with a specific class.


Try Now

The element selector

The element selector is used to select the elements based on the element name.

Or can select all div tags like this:


Try Now

The attribute selector

Attribute selector is used to select an element by one of its HTML attributes like an input’s type attribute.


Try Now 

Pin It on Pinterest

Share This