The jQuery selectors allow you to select and manipulate all HTML element(s).

jQuery selectors are used to “find” or “select” HTML elements based on their name, id, classes, types, attributes, values of attributes and much more.

All selectors in jQuery start with the dollar sign and parentheses: $(). Now here, I’m going to list some most usefule selectors below.

Selectors                           Description
$(“*”)                               Selects all elements HTML
$(this)                                Selects the current HTML element where you perform the action
$(“p.test”)                        Selects all <p> tag elements with class=”test”
$(“p:first”)                       Selects the first element of <p> tag
$(“ul li:first”)                   Selects the first element of <li> of the first <ul> element tag
$(“ul li:first-child”)          Selects the first element of <li> every <ul> element tag
$(“[href]”)                        Selects all elements with an href attribute
$(“a[target=’_blank’]”)   Selects all <a> elements with a target attribute value equal to “_blank”
$(“a[target!=’_blank’]”)  Selects all <a> elements with a target attribute value NOT equal to “_blank”
$(“:button”)                     Selects all <button> elements and <input> elements of type=”button”
$(“tr:even”)                      Selects all even <tr> elements
$(“tr:odd”)                       Selects all odd <tr> elements

News Reporter
IT Software and web development, Core PHP, JavaScript, JQuery, HTML, CSS, CakePHP, Angularjs, Codeigniter etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

error: