Mega Code Archive

 
Categories / JavaScript Tutorial / JQuery
 

The basic CSS Selectors supported by jQuery

Selector                  Description *                         Matches any element. E                         Matches element with tag name E. E F                       Matches elements with tag name F that are descendents of E. E>F                       Matches elements with tag name F that are direct children of E. E+F                       Matches elements F immediately preceded by sibling E. E~F                       Matches elements F preceded by any sibling E. E:has(F)                  Matches elements with tag name E that have at least one descendent with tag name F. E.C                       Matches elements E with class name C. Omitting E is the same as *.C. E#I                       Matches element E with id of I. Omitting E is the same as *#I. E[A]                      Matches elements E with attribute A of any value. E[A=V]                    Matches elements E with attribute A whose value is V. E[A^=V]                   Matches elements E with attribute A whose value begins with V. E[A$=V]                   Matches elements E with attribute A whose value ends with V. E[A*=V]                   Matches elements E with attribute A whose value contains V. $("p:even");                    selects all even <p> elements. $("tr:nth-child(1)");           selects the first row of each table. $("body > div");                selects direct <div> children of <body>. $("a[href$=pdf]");              selects links to PDF files. $("body > div:has(a)")          selects direct <div> children of <body>-containing links.