The next several exercises are timed. If you type slowly or dislike time pressure, feel free to increase the allotted time.
I spend a year programming these interactive exercises—then give them away free? Well, maybe I'm not as crazy as my wife says I am, because the free exercises sell quite a few books.
But free exercises alone aren't enough to sell a book. My book is a needle in a haystack, hidden among 12 million books on Amazon. And it's self-published, by an author who is not a household name.
The truth is, my book wouldn't be able to compete with books from big publishers like O'Reilly and Sams if it weren't for enthusiastic customer reviews. For me, reviews are the great equalizer.
I'm hoping that soon there'll be so many reviews for my book, it'll start setting sales records. At that point, authors will begin to think maybe it's not such a bad idea to include free interactive exercises in their package. One of those authors will be me.
Want to encourage more books like this? Spend two minutes writing a 20-word review on my book's Amazon page.
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. | $("button#b1").on("click"__ function() { | , | ^ *, *$ |
Fill in the blank. | $("button#b1").on("click", ________() { | function | ^ *function *$ |
Fill in the blank. | $("button#b1").on("click", function__ { | () | ^ *\(\)*$ |
What character is missing? | $("button#b1").on("click", function() | { | ^ *{ *$ |
5. Drag-and-drop: Holding down the left mouse button, drag the pieces of code onto the screen to code the first line that triggers an action when an image is clicked. | $("img").on("click", function() { | ||
Code the first line that triggers an action when any paragraph is double clicked. | $("p").on("dblclick", function() { | $`(`"`p`"`)`.`on`(`"`dblclick`"`comma`1spacefunction`(`)`1space{ | |
Code the first line that triggers an action when the user clicks in a form field whose ID is "city". | $("input#city").on("focus", function() { | ||
Code the next line. | $("button#b1").on("click", function() { $("img").hide(); | }); | ^ *}\); *$ |
Code the first line of code that triggers an event when a form with the ID "contact" is submitted. | $("form#contact").on("submit", function() { | ^ *\$\(•form#contact•\)\.on\(•submit•, function\(\) { *$ | |
Code the first line of code that triggers an event when any div whose class is "clickable" is clicked. | $("div.clickable").on("click", function() { | ^ *\$\(•div\.clickable•\)\.on\(•click•, function\(\) { *$ | |
Code the first 2 lines of code that hides all images when a button is clicked. Make up the button ID. | $("button#b2").on("click", function() { $("img").hide(); | ^ *\$\(•button#.+•\)\.on\(•click•, function\(\) {\n *\$\(•img•\)\.hide\(\); *$ | |
Code all 3 lines of code to add a class to all divs when a button is clicked. Make up the div class name and the button ID. | $("button#b2").on("click", function() { $("div").addClass("bigger"); }); | ^ *\$\(•button#.+•\)\.on\(•click•, function\(\) {\n *\$\(•div•\)\.addClass\(•.+•\);\n *}\); *$ | |
Code the first line that triggers an action when the user clicks in a form field whose ID is "city". | $("input#city").on("focus", function() { | ^ *\$\(•input#city•\)\.on\(•focus•\, function\(\) { *$ | |
Code the next line. | $("button#b1").on("click", function() { $("img").hide(); | }); | ^ *}\); *$ |
Code the first line of code that triggers an event when a form with the ID "contact" is submitted. | $("form#contact").on("submit", function() { | ^ *\$\(•form#contact•\)\.on\(•submit•, function\(\) { *$ | |
Code the first line of code that triggers an event when any div whose class is "clickable" is clicked. | $("div.clickable").on("click", function() { | ^ *\$\(•div\.clickable•\)\.on\(•click•, function\(\) { *$ | |
Code the first 2 lines of code that hides all images when a button is clicked. Make up the button ID. | $("button#b2").on("click", function() { $("img").hide(); | ^ *\$\(•button#.+•\)\.on\(•click•, function\(\) {\n *\$\(•img•\)\.hide\(\); *$ | |
Code all 3 lines of code to add a class to all divs when a button is clicked. Make up the div class name and the button ID. | $("button#b2").on("click", function() { $("div").addClass("bigger"); }); | ^ *\$\(•button#.+•\)\.on\(•click•, function\(\) {\n *\$\(•div•\)\.addClass\(•.+•\);\n *}\); *$ | |
http://jsfiddle.net/ASmarterWayToLearn/fq0ah9pr/ | |||
http://jsfiddle.net/ASmarterWayToLearn/9c7mneyp/ |