JQuery Selectors

The jQuery selectors are important aspects of the jQuery library. The jQuery selectors allow page elements to be selected. It supports selection of single element or multiple elements. These selectors use CSS syntax which allows identifying set of elements to operate upon with jQuery library methods. The important purpose of jQuery selector is to select elements and perform some actions on the selected elements. The jQuery selectors searches or selects HTML elements and performs intended action on those elements. jQuery selectors is one of the most powerful mechanism used in jQuery to search the elements. This concept is borrowed from the CSS language.

A selector identifies HTML element which will manipulate with jQuery code. A jQuery selector uses expressions to find out matching elements in the set of matched elements from the DOM. All types of jQuery selectors start with dollar sign and parentheses. i.e. $( ).

The table shows list of jQuery selectors with description.

SelectorDescription
(“*”)It selects all the elements.
(“#id”)It selects elements by ID attribute.
(“.class”)It selects elements by class name.
tagIt selects all the p elements.
:first-child selectorIt selects first matched element of their parent element on the page.
:last-child selectorIt selects last matched element of their parent element on the page.
:not selectorIt selects all the elements except the specified element that do not match given selector.
:gt() selectorIt returns all the elements which are greater than index value.
:lt() selectorIt returns all the elements which are less than index value.
:even selectorIt selects all the elements that have even index value.
:odd selectorIt selects all the elements that have odd index value.
:enabled selectorIt selects all the elements that are enabled.
:disabled selectorIt selects all the disabled elements.
:selected selectorIt selects all the elements that are in selected state.
:checked selectorIt selects all the elements that are checked or selected.
:input selectorIt selects all the input elements from input, select, textarea, button elements.
:text selectorIt selects all the elements that are of type text.
:button selectorIt selects all the elements that are of type button.
:has selectorIt selects all the elements with a descendant that matches specified selector.
:password selectorIt selects all the elements that are of type password.
:radio selectorIt selects all the elements that are of type radio.
:checkbox selectorIt selects all the elements that are of type checkbox.
:image selectorIt selects all the elements that are of type image.
:file selectorIt selects all the elements that are of type file.
:submit selectorIt selects all the elements that are of type submit.
:reset selectorIt selects all the elements that are of type reset.
:animated selectorIt selects all the elements that are under animated control.
:header selectorIt selects all the headers from h1 through h6.
:hidden selectorIt selects all the hidden elements.
:visible selectorIt selects all the visible elements.
:empty selectorIt selects all the elements which have no child elements.
:parent selectorIt selects all the elements that are parent to other elements including text nodes.
:contains selectorIt selects all the elements that contains the text.
[attribute]It selects all the elements that have attribute name or attribute value.
[attribute$=value]It selects all the elements that ends with a given string.
[attribute=value]It selects all the elements that equal to a certain value.
[attribute*=value]It returns all the elements that passed attribute value contains the passed value.
[attribute!=value]It selects all the elements that do not equal to certain value.

Comments

comments

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Speak Your Mind

*