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 = "Name of Our School";
Write the HTML code for a input text box and give it the class of score
<input class="score">
Write a jQuery selector to select a <p> tag.
Bonus for 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();
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();
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 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 "High School".
$(".school").val("Orchard");