The Jquery Library Harnesses The Power of Cascading Style Sheets
The Jquery Library Harnesses The Power of Cascading Style Sheets
and easily access elements or groups of elements in the Document Object Model (DOM).A jQuery
Selector is a function which makes use of expressions to find out matching elements from a DOM
based on the given criteria.
1. $("p > *"): This selector selects all elements that are children of a paragraph
element.
2. $("#specialID"): This selector function gets the element with id="specialID".
3. $(".specialClass"): This selector gets all the elements that have the class of
specialClass.
4. $("li:not(.myclass)"): Selects all elements matched by <li> that do not
have class="myclass".
5. $("a#specialID.specialClass"): This selector matches links with an id of specialID
and a class of specialClass.
6. $('*'): This selector selects all elements in the document.
1. $("p a.specialClass"): This selector matches links with a class of specialClass
declared within <p> elements.
2. $("ul li:first"): This selector gets only the first <li> element of the <ul>.
3. $("#container p"): Selects all elements matched by <p> that are
descendants of an element that has an id of container.
4. $("li > ul"): Selects all elements matched by <ul> that are children of
an element matched by <li>
5. $("strong + em"): Selects all elements matched by <em> that immediately
follow a sibling element matched by <strong>.$("p ~ ul"): Selects all
elements matched by <ul> that follow a sibling element matched by <p>.
6. $("code, em, strong"): Selects all elements matched by <code> or <em> or
<strong>.
7. $("p strong, .myclass"): Selects all elements matched by <strong> that are
descendants of an element matched by <p> as well as all elements that
have a class of myclass.
8. $(":empty"): Selects all elements that have no children.
9. $("p:empty"): Selects all elements matched by <p> that have no children.
10. $("div[p]"): Selects all elements matched by <div> that contain an element
matched by
<p>.