Tuesday, September 20, 2011

jQuery Selector


#No Syntax Description
---------------------------------------------------------------------------------------
1. $(this) Current HTML element
2. $(".intro") All elements with class="intro"
3. $("#intro") The first element with id="intro"
4. $("p") All <p> elements
5. $("p.intro") All <p> elements with class="intro"
6. $("p#intro") All <p> elements with id="intro"
7. $("p#intro:first-child") The first <p> element with id="intro"
8. $("ul li:first-child") The first <li> element of each <ul>
9. $("ul li:last-child") The last <li> element of each <ul>
10. $("ul li:nth-child(4)") The fourth <li> element of each <ul>
11. $("div#intro .head") All elements with class="head" and id="intro" of DIV
12. $("[href*='User']") All elements with href contains "User"
13. $("[href^='User']") All elements with href start with "User"
14. $("[href$='.html']") All elements with an href attribute
that ends with ".html"
15. $("[href*='User'] div") AND condition for Getting all element
which have href contains "User" and inner element div
16. $("[href*='User'],div") OR condition for Getting all element
which have href contains "User" or div element
17. $("[href!='UserInfo.html']") NOT condition for Getting all element
which have href not equle to "UserInfo.html"
18. $("div > input#User") Getting all element which have a parent element is
DIV and next element is INPUT have a id User
19. $("div").find("input#User") Getting all element of parent element is
DIV and child element is INPUT have a id User
20. $("div").not(".UserInfo, #UserId") Getting all div element which not have a
class USERINFO or id is USERID

No comments: