What character does every jQuery statement begin with?
$
When will the alert be triggered?
$("button").click(function () { alert("hello"); }
When the button is clicked
Declare a variable called school and set its value to the name of your school.
var school = "Orchard Academy";
Write the HTML code for a input text box and give it the class of score
<input class="score">
Will this expression evaluate to TRUE or FALSE?
var grade = 90; if (grade > 90)
FALSE
Write a jQuery selector to select a <p> tag.
Bonus 100 points:
Write a jQuery selector to select a <p class="blue"> tag by its class.
$("p")
$(".blue")
What is the name of the event when the user places their mouse cursor on an element?
.hover()
Set the value of a variable named numOfPeople to the sum of 5 and 6.
numOfPeople = 5 + 6;
Please write the code required to get the value from an input box
<input>
$("input").val();
Write an if statement (no body, just the first line) that tests whether age is not equal to 18.
if (age !== 18)
Name as many jQuery actions as you can
(50 points each)
.hide(), .show(), .toggle(), .slide(), .fade(), .css(), .text(), .append(), slideDown(), slideUp(), slideToggle(), fadeIn(), fadeOut()
Write the code to change the text in the paragraph to "Goodbye"
<p class="message">Hello</p>
$(".message").text("Goodbye");
If the value of price is 200, what is the value of the variable of total after the following line of code?
total = price + "10";
20010
In the following line of code, where is value that we get from the text box being stored?
$("input").val();
It isn't stored anywhere. Instead, we should put it in a variable:
var password = $("input").val();
What is the value of todayIsMyBirthday after this code runs?
birthday = "May 14"; if (birthday = "March 22") { todayIsMyBirthday = true; } else { todayIsMyBirthday = false; }
TRUE
Name as many jQuery events as you can
(50 points each)
.click(), .hover(), .mouseenter(), .mouseleave(), dblclick()
Write the code to add the word "movies" to the paragraph.
<p class="message">Let's go to the </p>
$(".message").append("movies");
If the value of the variable name is "Jeff", please create a new variable called greeting, and set its' value to "Hello, Jeff" using the variable name.
var greeting = "Hello, " + name;
With the following HTML:
<input class="age">
Write a line of code to get the value of the text box and store it in a variable called "age".
var age = $(".age").val();
Write an if statement that sets a variable named winner to "p1" if the value of a variable named p1hand is "rock" and the value of a variable named p2hand is "scissors".
if (p1hand === "rock" && p2hand === "scissors") { winner = "p1"; }
Write the jQuery to change the text color of the paragraph to blue.
<p>This is not blue...yet</p>
$("p").css("color", "blue");
Write a click handler for a button with a class of submit
$(".submit").click(function () { }
Write code to increase the value of the variable total by 4.
total = total + 4;
With the following HTML:
<input class="school">
Write a line of code to change the value of the text box to "Orchard".
$(".school").val("Orchard");
Write an if statement that sets a variable named type to "healthy" if the value of a variable named food is "fruit" or "vegetable", but sets type to "unhealthy" if not.
if (food === "fruit" || food === "vegetable"){ type = "healthy"; } else { type = "unhealthy"; }