February 2010
Beginner
400 pages
11h 13m
English
jQuery's strength is the ease with which you can select and manipulate elements on the page. You have used a selector method already to select all <div> elements that have an ID of div1:
$("#div1").html("hello jQuery");
jQuery supports many different ways to select an element or elements that should meet all but the most awkward requirements. Table 12-1 lists examples of other selection methods you might want to use.
| Selector | Selected |
|---|---|
| $("#div1") | Selects a <div> with an ID of div1. |
| $("div") | Selects all <div>s. |
| $("div.standardDiv") | Selects all <div>s with a class of standardDiv. |
| $(".standardDiv") | Selects all elements with a class of standardDiv. |
| $("#div4 #div5") | Selects a <div> with an ID of ... |