JAVASCRIPT & DHTML FINAL EXAM
QUESTIONS AND ANSWERS
A jQuery selector includes all but one of the following. Which one is it?
a) $ sign
b) quotation marks
c) parentheses
d) dot (.) operator - ANSWER-d
Which of the following jQuery methods can you use to get the value of an
input text box?
a) text()
b) text(value)
c) val()
d) val(value) - ANSWER-c
What does the follow jQuery code do? $("h2").prev();
a) Gets the h2 element that precedes the current element eve
b) Gets the element in the HTML that contains the selected h2 element
c) Gets the previous sibling of the selected h2 element
d) Gets the previous sibling of the selected h2 element that is an h2 element
- ANSWER-c
Which of the following jQuery methods would you use to execute a method
for each element in an array?
a) this()
b) item()
c) array()
d) each() - ANSWER-d
, What does the following jQuery code do? $("#image").attr("src", imageURL);
a) Gets the value of the src attribute for the element with an id of "image"
and stores it in a variable named imageURL
b) Sets the value of the src attribute for the element with an id of "image" to
the value in a variable named imageURL
c) Gets the values of the src attribute for each element with a class of
"image" and stores them in an array variable named imageURL
d) Sets the values of the src attribute for each element with a class of
"image" to the values in an array variable named imageURL - ANSWER-b
Code example 2-1
$("#faqs h2").click(function() {
$(this).toggleClass("minus"); if ($(this).attr("class") != "minus") {
$(this).next().hide();
}
else {
$(this).next().show();
}
});
(Refer to code example 2-1) What does the this keyword refer to in this code?
a) The click event method
b) The anonymous function for the click event method
c) The current h2 heading in the processing loop
d) The h2 heading that was clicked - ANSWER-d
Code example 2-1
$("#faqs h2").click(function() {
$(this).toggleClass("minus"); if ($(this).attr("class") != "minus") {
$(this).next().hide();
QUESTIONS AND ANSWERS
A jQuery selector includes all but one of the following. Which one is it?
a) $ sign
b) quotation marks
c) parentheses
d) dot (.) operator - ANSWER-d
Which of the following jQuery methods can you use to get the value of an
input text box?
a) text()
b) text(value)
c) val()
d) val(value) - ANSWER-c
What does the follow jQuery code do? $("h2").prev();
a) Gets the h2 element that precedes the current element eve
b) Gets the element in the HTML that contains the selected h2 element
c) Gets the previous sibling of the selected h2 element
d) Gets the previous sibling of the selected h2 element that is an h2 element
- ANSWER-c
Which of the following jQuery methods would you use to execute a method
for each element in an array?
a) this()
b) item()
c) array()
d) each() - ANSWER-d
, What does the following jQuery code do? $("#image").attr("src", imageURL);
a) Gets the value of the src attribute for the element with an id of "image"
and stores it in a variable named imageURL
b) Sets the value of the src attribute for the element with an id of "image" to
the value in a variable named imageURL
c) Gets the values of the src attribute for each element with a class of
"image" and stores them in an array variable named imageURL
d) Sets the values of the src attribute for each element with a class of
"image" to the values in an array variable named imageURL - ANSWER-b
Code example 2-1
$("#faqs h2").click(function() {
$(this).toggleClass("minus"); if ($(this).attr("class") != "minus") {
$(this).next().hide();
}
else {
$(this).next().show();
}
});
(Refer to code example 2-1) What does the this keyword refer to in this code?
a) The click event method
b) The anonymous function for the click event method
c) The current h2 heading in the processing loop
d) The h2 heading that was clicked - ANSWER-d
Code example 2-1
$("#faqs h2").click(function() {
$(this).toggleClass("minus"); if ($(this).attr("class") != "minus") {
$(this).next().hide();