The jQuery factory function $() is used to find elements on the page to work with. This function takes a string composed of CSS-like syntax, called a selector expression. Selector expressions are discussed in detail in Chapter 2, Selecting Elements.
Selector expressions
Simple CSS
Selector |
Matches |
* |
All elements. |
#id |
The element with the given ID. |
element |
All elements of the given type. |
.class |
All elements with the given class. |
a, b |
Elements that are matched by a or b. |
a b |
Elements b that are descendants of a. |
a > b |
Elements b that are children of a. |
a + b |
Elements b that immediately follow a. |
a ~ b |
Elements b that are siblings of a and follow a. |