The basic CSS Selectors supported by jQuery : css function « jQuery « JavaScript DHTML






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.

   
  








Related examples in the same category

1.Add border to DIV
2.Add paragraph and set the style
3.Define CSS in an array and set
4.Get CSS value
5.Set two CSS value in CSS function
6.Nested style setting
7.Use the rgb function with JQuery
8.Use CSS value when creating new tag
9.css(name): Return a style property on the matched element.
10.css(properties): set several style properties on matched elements.
11.css(name, value): If a number is provided, it is automatically converted into a pixel value.
12.Adds a background and text color to all the headers on the page.
13.Sets the background color of the page to black.