jQuery
Music (Just kidding, more jQuery)
Variables
Input
Conditionals
100

What character does every jQuery statement begin with?

$

100

When will the alert be triggered?

$("button").click(function () {
    alert("hello");
}

When the button is clicked 

100

Declare a variable called school and set its value to the name of your school.

var school = "Orchard Academy";
100

Write the HTML code for a input text box and give it the class of score

<input class="score">

100

Will this expression evaluate to TRUE or FALSE?

var grade = 90;
if (grade > 90)


FALSE

200

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")

200

What is the name of the event when the user places their mouse cursor on an element?

.hover()

200

Set the value of a variable named numOfPeople to the sum of 5 and 6. 

numOfPeople = 5 + 6;
200

Please write the code required to get the value from an input box

<input>

$("input").val();

200

Write an if statement (no body, just the first line) that tests whether age is not equal to 18.

if (age !== 18)
300

Name as many jQuery actions as you can

(50 points each)

.hide(), .show(), .toggle(), .slide(), .fade(), .css(), .text(), .append(), slideDown(), slideUp(), slideToggle(), fadeIn(), fadeOut()

300

Write the code to change the text in the paragraph to "Goodbye"

<p class="message">Hello</p>

$(".message").text("Goodbye");

300

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

300

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();

300

What is the value of todayIsMyBirthday after this code runs?

birthday = "May 14";
if (birthday = "March 22") {
	todayIsMyBirthday = true;	
}
else {
	todayIsMyBirthday = false;
}

TRUE

400

Name as many jQuery events as you can

(50 points each)

.click(), .hover(), .mouseenter(), .mouseleave(), dblclick()

400

Write the code to add the word "movies" to the paragraph.

<p class="message">Let's go to the </p>

$(".message").append("movies");

400

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;
400

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();
400

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";
}
500

Write the jQuery to change the text color of the paragraph to blue.

<p>This is not blue...yet</p>

$("p").css("color", "blue");

500

Write a click handler for a button with a class of submit

$(".submit").click(function () {
	
}
500

Write code to increase the value of the variable total by 4.

total = total + 4;

500

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");

500

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";
}
M
e
n
u