Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Multiple Choice 1) Which of the following do you use to attach an event handler?

ID: 3870836 • Letter: M

Question

Multiple Choice

1)

Which of the following do you use to attach an event handler?

(1pts)

selector

method

event method

script element

2)

You include the jQuery library in your website by coding a

(1pts)

head element

body element

script element

link element

3)

Which of the following statements about a Content Delivery Network (CDN) is true?

(1pts)

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

It allows you to download jQuery and include it in your application.

It can only be used by the modern browsers.

It works whether or not you’re connected to the Internet.

4)

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?

(1pts)

toggle()

toggleClass()

changeClass()

switchClass()

5)

The jQuery functions are coded and tested for

(1pts)

security

cross-browser compatibility

speed

readability

6)

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?

(1pts)

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

7)

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?

(1pts)

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.

8)

Which of the following methods would you use to execute a method for each element in an array?

(1pts)

html()

hide()

every()

each()

9)

Which of the following code statements sets the text of an element?

(1pts)

text()

text(value)

val()

val(value)

10)

Which of the following events occurs when the user moves the mouse pointer over an element and then clicks on it?

(1pts)

click

mouseover

hover

all of the above

Explanation / Answer

1) Which of the following do you use to attach an event handler?

Answer: method – on() method is used to attach an event handler

2) You include the jQuery library in your website by coding a

Answer: script element

3) Which of the following statements about a Content Delivery Network (CDN) is true?

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

4) 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?

Answer:  toggleClass()

5) The jQuery functions are coded and tested for

Answer: cross-browser compatibility