JavaScript Chapter 8

Ace your homework & exams now with Quizwiz!

When does the ready() event handler run? A. As soon as the browser starts. B. As soon as the browser gets the HTTP response for the page. C. As soon as the browser starts to load the page. D. As soon as the browser builds the DOM.

As soon as the browser builds the DOM.

Which of the following expressions gets the value of a text box with an id of "message"? A. $("#message").text B. $("#message").text() C. $("#message").val() D. $("#message").nodeValue()

$("#message").val()

Which of the following statements sets the text of a <p> element with an id of "ship" A. $("#ship").text = "Shipping is free."; B. $("#ship").text("Shipping is free."); C. $("#ship").val("Shipping is free."); D. $("#ship").nodeValue("Shipping is free.");

$("#ship").text("Shipping is free.");

A jQuery selector includes all but one of the following. Which one is it? A. $ sign B. quotation marks C. parentheses D. dot operator

dot operator

Which of the following methods would you use to execute a method for each element in an array? A. html() B. hide() C. every() D. each()

each()

With jQuery, which of the following do you use to attach an event handler? A. selector B. method C. event method D. script element

event method

Object chaining works because each method returns the appropriate A. object B. selector C. method D. event method

object

You include the jQuery library in your website by coding a A. head element B. body element C. script element D. link element

script element

$("#faqs h2").click( evt => { const h2 = evt.currentTarget; $(h2).toggleClass("minus"); if ($(h2).attr("class") !== "minus") { $(h2).next().hide(); } else {$(h2).next().show(); } evt.preventDefault();}); What does the parameter named evt refer to? A. the jQuery object B. the Event object C. the click() event method D. the selector

the Event object

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? A. toggle() B. toggleClass() C. changeClass() D. switchClass()

toggleClass()

$("#faqs h2").click( evt => { const h2 = evt.currentTarget; $(h2).toggleClass("minus"); if ($(h2).attr("class") !== "minus") { $(h2).next().hide(); } else {$(h2).next().show(); } evt.preventDefault();}); Assuming none of the h2 elements include a class attribute when the application starts, what happens the first time the user clicks on an h2 element? A. A class named "minus" is added to the element and the element's next sibling is displayed. B. A class named "minus" is added to the element and the element's next sibling is hidden. C. Nothing happens because the click() event method is used instead of the on() event method. D. Nothing happens because the event object isn't passed to the function for the event handler.

A class named "minus" is added to the element and the element's next sibling is displayed.

What does the following jQuery code do? $("h2").prev(); A. Gets the h2 element that precedes the current element B. Gets the element in the HTML that precedes the selected h2 element C. Gets the previous sibling of each selected h2 element D. Gets the previous sibling of each selected h2 element that is also an h2 element

Gets the previous sibling of each selected h2 element

Which of the following statements about a Content Delivery Network (CDN) is true? A. It allows you to get jQuery from another website and include it in your application. B. It allows you to download jQuery and include it in your application. C. It can only be used by the modern browsers. D. It works even if you're not connected to the Internet.

It allows you to get jQuery from another website and include it in your application.

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

Sets the value of the src attribute for the element with an id of "image" to the value in a variable named imageURL

$("#faqs h2").click( evt => { const h2 = evt.currentTarget; $(h2).toggleClass("minus"); if ($(h2).attr("class") !== "minus") { $(h2).next().hide(); } else {$(h2).next().show(); } evt.preventDefault();}); What does evt.currentTarget refer to in this code? A. The click() event method B. The anonymous function for the click() event method C. All h2 elements within the element with an id of "faqs" D. The h2 element that was clicked

The h2 element that was clicked

What is object chaining? A. When you code each method in a separate statement. B. When you code methods that do similar things in a group of statements. C. When you use a single statement to call one method from another method. D. When you pass one method to another method as a parameter.

When you use a single statement to call one method from another method.

Which of the following events occurs when the user moves the mouse pointer over an element and then clicks on it? A. click B. mouseover C. hover D. all of the above

all of the above

jQuery is A. a programming language B. a part of the CSS3 specification C. an open-source JavaScript library D. an extension of the Chrome browser

an open-source JavaScript library


Related study sets

MEDSURG II: Saunders Cardiovascular

View Set

Jackson Weber Complex Pre/Post Quiz

View Set

PREP U 1340- ch 50 Caring for Clients with Disorders of the Endocrine System

View Set

Simulation Lab 9.1: Module 09 Create a Path MTU Black Hole

View Set

S-130 Module 12 (Optional Knowledge)

View Set