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
When you replace an image with a larger version of the same image, what do you need to change in the following code in addition to the source? Answer with one word. | <img src="loris_small" width="50px;"> | width | ^ *width *$ |
Instead of changing the width and height attributes for the larger image, you can ______ them. | remove | ^ *remove *$ | |
What is the keyword for removing an attribute? | removeAttr | ^ *removeAttr *$ | |
What is the keyword for removing an element like a div, paragraph, or image? | remove | ^ *remove *$ | |
5. Drag-and-drop: Holding down the left mouse button, drag the pieces of code onto the screen to remove all classes and replace the id. | $(this).removeAttr("class").attr("id", "bug"); | ||
In a single statement, replace the class of $(this), then remove all classes. The new class is "that". | $(this).attr("class", "that").removeAttr("class"); | $(this)`.`attr`(`"`class`"`comma`1space"`that`"`)`.`remove`Attr`(`"`class`"`)`; | |
Replace all classes of $(this) with the two classes "big" and "bright". | $(this).attr("class", "big bright"); | ||
Remove all classes from two paragraphs. Make up the ids of the two paragraphs. | $("p#intro, p#close").removeAttr("class"); | ^ *\$\(•p#.+, p#.+•\).removeAttr\(•class•\); *$ | |
In a single statement, add a class to $(this) and replace its id. Make up the class name and id. | $(this).addClass("big").attr("id", "bright"); | ^ *\$\(this\)\.addClass\(•.+•\)\.attr\(•id•, •.+•\); *$ | |
Assign an id name to a variable. Then replace the id of $(this) with the new id using the variable. Make up the variable name and id. | var replacement = "loris"; $(this).attr("id", replacement); | ^ *var ([a-zA-Z$_][a-zA-Z$_0-9]*) = •.+•;\n *\$\(this\)\.attr\(•id•, \1\); *$ | |
Selecting $(this), replace the id with a new id and all the classes with a new class. Make up the new id and class name. | $(this).attr("id", "loris").attr("class", "pets"); | ^ *\$\(this\)\.attr\(•id•, •.+•\)\.attr\(•class•, •.+•\); *$ | |
When the user clicks the button whose id is "plain_text" all classes are removed from all paragraphs. | $("button#plain_text").on("click", function() { $("p").removeAttr("class"); }); | ^ *\$\(•button#plain_text•\)\.on\(•click•, function\(\) {\n *\$\(•p•\)\.removeAttr\(•class•\);\n *}\); *$ | |
Replace all classes of $(this) with the two classes "big" and "bright". | $(this).attr("class", "big bright"); | ^ *\$\(this\)\.attr\(•class•, •big bright•\); *$ | |
Remove all classes from two paragraphs. Make up the ids of the two paragraphs. | $("p#intro, p#close").removeAttr("class"); | ^ *\$\(•p#.+, p#.+•\).removeAttr\(•class•\); *$ | |
In a single statement, add a class to $(this) and replace its id. Make up the class name and id. | $(this).addClass("big").attr("id", "bright"); | ^ *\$\(this\)\.addClass\(•.+•\)\.attr\(•id•, •.+•\); *$ | |
Assign an id name to a variable. Then replace the id of $(this) with the new id using the variable. Make up the variable name and id. | var replacement = "loris"; $(this).attr("id", replacement); | ^ *var ([a-zA-Z$_][a-zA-Z$_0-9]*) = •.+•;\n *\$\(this\)\.attr\(•id•, \1\); *$ | |
Selecting $(this), replace the id with a new id and all the classes with a new class. Make up the new id and class name. | $(this).attr("id", "loris").attr("class", "pets"); | ^ *\$\(this\)\.attr\(•id•, •.+•\)\.attr\(•class•, •.+•\); *$ | |
When the user clicks the button whose id is "plain_text" all classes are removed from all paragraphs. | $("button#plain_text").on("click", function() { $("p").removeAttr("class"); }); | ^ *\$\(•button#plain_text•\)\.on\(•click•, function\(\) {\n *\$\(•p•\)\.removeAttr\(•class•\);\n *}\); *$ | |
http://jsfiddle.net/ASmarterWayToLearn/o1ej18aj/ | |||
http://jsfiddle.net/ASmarterWayToLearn/hy1bbqm0/ |