Jquery Selectors
For more tutorials visit our site www.prashobh.webs.com (a make it easy product)
jQuery selectors allow to select and manipulate HTML elements as a group or as a single element.Selectors allow us to get the exact element/attribute you want from your HTML document.jQuery supports the existing CSS Selectors, and in addition, it has some own custom selectors.All type of selectors in jQuery, start with the dollar sign and parentheses: $().
Examples of jQuery Selectors
$("*") selects all elements.
$("p") selects all <p> elements.
$("p.intro") selects all <p> elements with class="intro".
$("p#intro") selects the first <p> elements with id="intro"
$(":animated") selects all elements that are currently animated.
$(":button") selects all <button> elements and <input> elements of
type="button"
$(":even") selects even elements.
$(":odd") selects odd elements.
Some more example
$(this) Selects the current HTML element
$("p#intro:first") Selects the first <p> element with id="intro"
$(".intro") Selects all elements with class="intro"
$("#intro") Selects the first element with id="intro"
$("ul li:first") Selects the first <li> element of the first <ul>
$("ul li:first-child") Selects the first <li> element of every <ul>
$("[href]") Selects all elements with an href attribute
$("[href$='.jpg']") Selects all elements with an href attribute that ends with ".jpg"
$("[href='#']") Selects all elements with an href value equal to "#"
$("[href!='#']") Selects all elements with an href value NOT equal to "#"
$("div#intro .head") Selects all elements with class="head" inside a <div> element with id="intro"
No comments:
Post a Comment