JQuery Selectors
jQuery selectors allow you to select HTML elements (or groups of elements) by element name, attribute name or by content.
elements. elements with class="intro". elements with id="demo".jQuery Selectors
Till now we have learnt how to select different HTML elements. It is a key point to learn how jQuery selects exactly the elements you want to apply an effect to.
Note: jQuery selectors allow you to select HTML elements (or groups of elements) by element name, attribute name or by content.jQuery Element Selectors
jQuery uses CSS selectors to select HTML elements.
$("p") selects all
$("p.intro") selects all
$("p#demo") selects all jQuery Attribute Selectors
jQuery uses XPath expressions to select elements with given attributes.
$("[href]") select all elements with an href attribute.
$("[href='#']") select all elements with an href value equal to "#".
$("[href!='#']") select all elements with an href attribute NOT equal to "#".
$("[href$='.jpg']") select all elements with an href attribute that ends with ".jpg".jQuery CSS Selectors
jQuery CSS selectors can be used to change CSS properties for HTML elements.
The following example changes the background-color of all p elements to red:
$("p").css("background-color","red");