JavaScript Question 11 (1 point) When does the ready() event handler run? Questi
ID: 3917905 • Letter: J
Question
JavaScript
Question 11 (1 point)
When does the ready() event handler run?
Question 11 options:
As soon as the browser starts.
As soon as the JavaScript load event is done.
As soon as all the page elements are loaded in the browser.
As soon as the Document Object Model is built.
Save
Question 12 (1 point)
What does the following jQuery code do?
$("h2").prev();
Question 12 options:
Gets the h2 element that precedes the current element
Gets the element in the HTML that precedes the selected h2 element
Gets the previous sibling of the selected h2 element
Gets the previous sibling of the selected h2 element that is an h2 element
Save
Question 13 (1 point)
What does the following jQuery code do?
$("#image").attr("src", imageURL);
Question 13 options:
Gets the value of the src attribute for the element with an id of “image” and stores it in a variable named imageURL
Sets the value of the src attribute for the element with an id of “image” to the value in a variable named imageURL
Gets the values of the src attribute for each element with a class of “image” and stores them in an array variable named imageURL
Sets the values of the src attribute for each element with a class of “image” to the values in an array variable named imageURL
Save
Question 14 (1 point)
Which of the following methods would you use to remove a class if it’s present or add a class if it isn’t present?
Question 14 options:
toggle()
toggleClass()
changeClass()
switchClass()
Save
Question 15 (1 point)
Which of the following methods would you use to execute a method for each element in an array?
Question 15 options:
html()
hide()
every()
each()
Save
Question 16 (1 point)
Which of the following events occurs when the user moves the mouse pointer over an element and then clicks on it?
Question 16 options:
click
mouseover
hover
all of the above
Save
Question 17 (1 point)
Code example 8-1
$("#faqs h2").click(function() {
$(this).toggleClass("minus");
if ($(this).attr("class") != "minus") {
$(this).next().hide();
}
else {
$(this).next().show();
}
});
(Refer to code example 8-1) What does the this keyword refer to in this code?
Question 17 options:
The click() event method
The anonymous function for the click() event method
The current h2 heading in the processing loop
The h2 heading that was clicked
Save
Question 18 (1 point)
Code example 8-1
$("#faqs h2").click(function() {
$(this).toggleClass("minus");
if ($(this).attr("class") != "minus") {
$(this).next().hide();
}
else {
$(this).next().show();
}
});
(Refer to code example 8-1) If none of the h2 elements that use this event handler include a class attribute when the application starts, what happens the first time the user clicks on an h2 element?
Question 18 options:
A class named “minus” is added to the element and the element’s next sibling is displayed.
A class named “minus” is added to the element and the element’s next sibling is hidden.
Nothing happens because the click() event method is used instead of the on event method.
Nothing happens because the event object isn’t passed to the function for the event handler.
Save
Question 19 (1 point)
What does the evt variable refer to in this code?
$("#faqs h2").click(function(evt) {
evt.preventDefault();
};
Question 19 options:
the jQuery object
the event object
the this keyword
the selector
Save
As soon as the browser starts.
As soon as the JavaScript load event is done.
As soon as all the page elements are loaded in the browser.
As soon as the Document Object Model is built.
Explanation / Answer
1)The ready() event handler run As soon as the Document Object Model is built.
Explanation:
----------
when the DOM (document object model) has been loaded the ready() event handler run.
Answer: D
2) $("h2").prev();
Gets the previous sibling of the selected h2 element
Explanation:
----------
traverse backwards along sibling elements in the DOM tree, instead of forward.
3)
$("#image").attr("src", imageURL);
Sets the value of the src attribute for the element with an id of “image” to the value in a variable named imageURL.
Explanation:
------------
In the above tag we can see the # tag so ot represents the ID but the if the image is assigned with the .Image it represents class.
Answer: B
4)
Answer: B
toggleClass() is the method that use to remove a class if it’s present or add a class if it isn’t present.
5) Answer :D
each() is used to execute a method for each element in an array.
6)
Answer: D)All of the above
All the events(click,mouseover,hover) will occur when the user moves the mouse pointer over an element and then clicks on it.
7)This keyword refer to the current h2 heading in the processing loop.
Answer: C
8)
Code example 8-1
$("#faqs h2").click(function() {
$(this).toggleClass("minus");
if ($(this).attr("class") != "minus") {
$(this).next().hide();
}
else {
$(this).next().show();
}
});
Answer:A A Class Named "minus" is added to the element and the element's next sibling is displayed
9)
$("#faqs h2").click(function(evt) {
evt.preventDefault();
};
Answer:B evt variable refer to the event object in the given code.
Thanks have a great day. please comment if you have any doubt on any answer.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.