The next several exercises are timed. If you type slowly or dislike time pressure, feel free to increase the allotted time.
Name and email required. Check any number of boxes.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
0
0
0
Fill in the blank to replace the ID. | $("div#d1")_____("id", "d2"); | .attr | ^ *\.attr *$ |
Fill in the blank to replace the ID. | $("div#d1").attr(_____ "d2"); | "id", | ^ *•id•, *$ |
Fill in the blank to replace the original ID with an ID of "d2". | $("div#d1").attr___________ | ("id", "d2"); | \(•id•, •d2•\); |
Fill in the blank to replace the original ID with an ID of "d2". | $("div#d1")._______________ | attr("id", "d2"); | attr\(•id•, •d2•\); |
5. Drag-and-drop: Holding down the left mouse button, drag the pieces of code onto the screen to select an image whose ID is "wolf" and change the ID to "dog". | $("img#wolf").attr("id", "dog"); | ||
Replace the ID of a div whose original ID is "main". The new ID is "secondary". | $("div#main").attr("id", "secondary"); | $`(`"`div`#`main`"`)`.`attr`(`"`id`"`comma1space`"`secondary`"`)`; | |
Replace the ID of an image whose original ID is "top". The new ID is "bottom". | $("img#top").attr("id", "bottom"); | ||
Replace the ID of a paragraph. Make up both the original and the new ID. | $("p#paragraph2").attr("id", "paragraph1"); | ^ *\$\(•p#.+•\)\.attr\(•id•, •.+•\); *$ | |
Selecting a particular image, replace any original classes with a new class. Make up the ID and new class name. | $("img#product").attr("class", "big"); | ^ *\$\(•img#.+•\)\.attr\(•class•, •.+•\); *$ | |
Replace any classes already assigned to all h3 headings and paragraphs with a new class. Use the short form for selecting multiple elements. Make up the new class name. | $("h3, p").attr("class", "prominent"); | ^ *\$\(•h3, p•\)\.attr\(•class•, •.+•\); *$ | |
A div whose ID is "details" has two classes, "small" and "faint". Using the attr() method, retain the class "small" and replace the class "faint" with "bold". | $("div#details").attr("class", "small bold"); | ^ *\$\(•div#details•\)\.attr\(•class•, •small bold•\); *$ | |
When the user mouses over any paragraph, any classes it has are replaced by the class "big". | $("p").on("mouseover", function() { $(this).attr("class", "big"); }); | ^ *\$\(•p•\)\.on\(•mouseover•, function\(\) {\n *\$\(this\)\.attr\(•class•, •big•\);\n *}\); *$ | |
Replace the ID of an image whose original ID is "top". The new ID is "bottom". | $("img#top").attr("id", "bottom"); | ^ *\$\(•img#top•\)\.attr\(•id•, •bottom•\); *$ | |
Replace the ID of a paragraph. Make up both the original and the new ID. | $("p#paragraph2").attr("id", "paragraph1"); | ^ *\$\(•p#.+•\)\.attr\(•id•, •.+•\); *$ | |
Selecting a particular image, replace any original classes with a new class. Make up the ID and new class name. | $("img#product").attr("class", "big"); | ^ *\$\(•img#.+\)\.attr\(•class•, •.+•\); *$ | |
Replace any classes already assigned to all h3 headings and paragraphs with a new class. Use the short form for selecting multiple elements. Make up the new class name. | $("h3, p").attr("class", "prominent"); | ^ *\$\(•h3, p•\)\.attr\(•class•, •.+•\); *$ | |
A div whose ID is "details" has two classes, "small" and "faint". Using the attr() method, retain the class "small" and replace the class "faint" with "bold". | $("div#details").attr("class", "small bold"); | ^ *\$\(•div#details•\)\.attr\(•class•, •small bold•\); *$ | |
When the user mouses over any paragraph, any classes it has are replaced by the class "big". | $("p").on("mouseover", function() { $(this).attr("class", "big"); }); | ^ *\$\(•p•\)\.on\(•mouseover•, function\(\) {\n *\$\(this\)\.attr\(•class•, •big•\);\n *}\); *$ | |
http://jsfiddle.net/ASmarterWayToLearn/0vukws9h/ | |||
http://jsfiddle.net/ASmarterWayToLearn/tcn05d5p/ |