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
Code the first line of a function that listens for a form submission and executes some code when the submission occurs. Make up the form id. | $("form#names").on("submit", function() { | ^ *\$\(•form#.+•\)\.on\(•submit•, function\(\) { *$ | |
Assign to a legally-named variable a user's entry in a form field. Make up the variable name and the field id. | var entry = $("input#name_first").val(); | ^ *var ([a-zA-Z$_][a-zA-Z$_0-9]*) = \$\(•input#.+•\).val\(\); *$ | |
In a single statement, do all of this: Concatenate two pieces of text that have been assigned to two variables. Assign the concatenation to a third variable. Make up all the variable names. | var fullName = nameFirst + nameLast; | ^ *var ([a-zA-Z$_][a-zA-Z$_0-9]*) *= *([a-zA-Z$_][a-zA-Z$_0-9]*) \+ ([a-zA-Z$_][a-zA-Z$_0-9]*); *$ | |
In a single statement, do all of this: Concatenate a text string and a variable. Assign the concatenation to a second variable. Make up the variable names and the string. | var combo = "Hi" + nameFirst; | ^ *var ([a-zA-Z$_][a-zA-Z$_0-9]*) = •.+• \+ ([a-zA-Z$_][a-zA-Z$_0-9]*); *$ | |
5. Drag-and-drop: Holding down the left mouse button, drag the pieces of code onto the screen to concatenate a string and two variables and insert the text in a heading. | $("h4#personalizedQuote").text("Personal Quote for " + first_name + " " + last_name); | ||
Assign the value in the field whose id is "city" to the variable cit. | var cit = $("input#city").val(); | var`1spacecit`1space=`1space`$`(`"`input`#`city`"`)`.`val`(`)`; | |
Assign to the variable combo the concatenation of "Hi " and the variable name_first. | var combo = "Hi" + name_first | ||
Insert in a form field the entry the user has made in another form field. Make up the ids. | $("input#entry_2").val($("input#entry_1").val()); | ^ *\$\(•input#.+•\)\.val\(\$\(•input#.+•\)\.val\(\)\); *$ | |
Code the first two lines of jQuery that listen for a form to be submitted--and, when it happens--assign the user's entry in a field to a variable. Make up the ids and the variable name. | $("form#info").on("submit", function() { var cit = $("input#city").val(); | ^ *\$\(•form#.+•\)\.on\(•submit•, function\(\) {\n *var ([a-zA-Z$_][a-zA-Z$_0-9]*) = \$\(•input#.+•\)\.val\(\); *$ | |
When the user mouses over a certain paragraph, concatenate its text with the word "now" and insert the concatenation back into the paragraph. Make up the paragraph's id. | $("p#urge").on("mouseover", function() { $(this).text($(this).text() + "now"); }); | ^ *\$\(•p#.+•\)\.on\(•mouseover•, function\(\) {\n *\$\(this\)\.text\(\$\(this\)\.text\(\) *\+ *•now•\);\n *}\); *$ | |
Code the first two lines of jQuery that listen for the user to click in a form field and, when it happens, insert text stored in a variable into the field. Make up the field's id and the variable name. | $("input#cit").on("focus", function() { $(this).val(cityEntered); | ^ *\$\(•input#.+•\)\.on\(•focus•, function\(\) {\n *\$\(this\)\.val\(([a-zA-Z$_][a-zA-Z$_0-9]*)\); *$ | |
When the user submits a form, her entry in the field whose id is name_first is assigned to a variable. Make up the form's id and the variable name. | $("form#contact").on("submit", function() { var first = $("input#name_first").val(); }); | ^ *\$\(•form#.+•\)\.on\(•submit•, function\(\) {\n *var .+ = \$\(•input#name_first•\)\.val\(\);\n *}\); *$ | |
Assign to the variable combo the concatenation of "Hi " and the variable name_first. (Don't forget the space after Hi.) | var combo = "Hi " + name_first; | ^ *var combo = •Hi • \+ name_first; *$ | |
Insert in a form field the entry the user has made in another form field. Make up the ids. | $("input#entry_2").val($("input#entry_1").val()); | ^ *\$\(•input#.+•\)\.val\(\$\(•input#.+•\)\.val\(\)\); *$ | |
Code the first two lines of jQuery that listen for a form to be submitted--and, when it happens--assign the user's entry in a field to a variable. Make up the ids and the variable name. | $("form#info").on("submit", function() { var cit = $("input#city").val(); | ^ *\$\(•form#.+•\)\.on\(•submit•, function\(\) {\n *var ([a-zA-Z$_][a-zA-Z$_0-9]*) = \$\(•input#.+•\)\.val\(\); *$ | |
When the user mouses over a certain paragraph, concatenate its text with the word "now" and insert the concatenation back into the paragraph. Make up the paragraph's id. | $("p#urge").on("mouseover", function() { $(this).text($(this).text() + "now"); }); | ^ *\$\(•p#.+•\)\.on\(•mouseover•, function\(\) {\n *\$\(this\)\.text\(\$\(this\)\.text\(\) *\+ *•now•\);\n *}\); *$ | |
Code the first two lines of jQuery that listen for the user to click in a form field and, when it happens, insert text stored in a variable into the field. Make up the field's id and the variable name. | $("input#cit").on("focus", function() { $(this).val(cityEntered); | ^ *\$\(•input#.+•\)\.on\(•focus•, function\(\) {\n *\$\(this\)\.val\(([a-zA-Z$_][a-zA-Z$_0-9]*)\); *$ | |
When the user submits a form, her entry in the field whose id is name_first is assigned to a variable. Make up the form's id and the variable name. | $("form#contact").on("submit", function() { var first = $("input#name_first").val(); }); | ^ *\$\(•form#.+•\)\.on\(•submit•, function\(\) {\n *var .+ = \$\(•input#name_first•\)\.val\(\);\n *}\); *$ | |
http://jsfiddle.net/ASmarterWayToLearn/L8ts92ay/ | |||
http://jsfiddle.net/ASmarterWayToLearn/4eh04nvn/ |