Practice Quiz



This practice quiz is posted to help you prepare for the final exam. The questions here are similar to those that will be on the exam. (Some of them may actually be on the exam.) Mark your selections using the radio buttons. Answers are shown by clicking the button at the bottom of the page.

  1. The recommended way to include the jQuery library is
    1. to embed the jQuery code in the HTML file that uses it.
    2. to download the development version and save it to a directory in your web site.
    3. to insert the jQuery code into your own script file.
    4. to load it from a CDN like Google or Microsoft.
  2. The HTML5 attribute defer in a script tag tells the browser to
    1. only download the script if a function it contains is actually used.
    2. download the script but don't execute it.
    3. download the script in parallel with rendering the page; execute the script when it is downloaded.
    4. wait to download the script till after the document is ready.
  3. What is the effect of this jQuery statement?
    $("div p").hide();
    1. Hides the first paragraph that is a descendant of a div.
    2. Hides all divs that are descendants of a paragraph.
    3. Hides all paragraphs that are descendants of a div.
    4. Nothing: the selector is invalid.
  4. Which is a correct way to create a new div element with content “Hello” using jQuery?
    1. $("div").text("Hello");
    2. $("div").append("Hello");
    3. $("<div>").append("Hello");
    4. $("<div>").text("Hello");
  5. "Chaining" in jQuery refers to
    1. writing a statement in which a series of jQuery methods are placed in a chain, connected by the “.” operator.
    2. concatenating strings that are providing content for a jQuery method.
    3. jQuery methods automatically looping over the selected elements.
    4. connecting or “chaining” a jQuery method to a plain object by wrapping it in a jQuery object
  6. If e is an element selected by a jQuery selector, then the difference between the e.after() and e.append() methods is
    1. e.after() creates a sibling element of e whereas e.append() creates a child.
    2. e.after() creates a child element of e whereas e.append() creates a sibling.
    3. e.append() inserts the new element before e whereas e.after() inserts it after e.
    4. no difference; the methods are synonymous.
  7. The jQuery method .css()
    1. with parameter of form "property:value", sets the value of the CSS property.
    2. with parameter of form "property", returns the value of the CSS property.
    3. should be used in preference to manipulating classes.
    4. all of the above.
  8. Event handlers attached to elements by jQuery can be removed with the jQuery method
    1. .remove()
    2. .disable()
    3. .event()
    4. .off()
  9. Some jQuery methods accept a callback function as a parameter, which
    1. is an event handler that is called when the selected element is clicked.
    2. is called during processing of the selected element, and returns a value that is used by the method, e.g. as content.
    3. requests content from the server.
    4. pops up a dialog box to request input from the user.