wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

uCertify JavaScript Chapter 9 and 10

Total questions: 21

Worksheet time: 11mins

Name
Class
Date
1.

Which of the following methods returns an array of all the elements in a Webpage, with a specified class name?

a)

getElementsByName

b)

getElementsByTagName

c)

getElementsByClassName

d)

getElementByClassName

2.

Which method allows you to delete entire HTML attributes from an element?

a)

getElementById

b)

setAttribute

c)

innerHTML

d)

removeAttribute

3.

Which method retrieves the corresponding value of an attribute?

a)

getAttribute

b)

setAttribute

c)

removeAttribute

d)

innerHTML

4.

Which of the following methods will access all occurrences in the page of an element with a specified name value and return them in an array?

a)

getElementsByTagName

b)

getElementById

c)

innerHTML

d)

getElementsByName

5.

Which line of code will center <div id="mydiv"> on the page?

a)

document.getElementsByName("mydiv").setAttribute("align", "center");

b)

document.getElementById("mydiv").getAttribute("align", "center");

c)

document.getElementsByName("mydiv").getAttribute("align", "center");

d)

document.getElementById("mydiv").setAttribute("align", "center");

6.

Which of the following methods lets you access all occurrences of an HTML tag in a Webpage?

a)

getElementByID

b)

getElementsByName

c)

getElementsByTagName

d)

innerHTML

7.

Which method will return only the first occurrence of a specified element in a script, rather than finding all occurrences of a specified element and returning them in an array?

a)

getElementsByTagName

b)

getElementById

c)

innerHTML

d)

getElementsByName

8.

In Web development, what is the ability to change HTML "on the fly"?

a)

To change Webpage content from X/HTML to JavaScript

b)

To change HTML on a Webpage when needed, even after it renders

c)

To change a Website from static content to interactive content

d)

To change Webpage content by requesting user input

9.

What happens if your script runs the document.write method after the page is rendered (i.e., finished loading)?


*hint* 9.7 Appending Text to the DOM

a)

It will append the document.write content to the end of the page without overwriting the existing page content.

b)

The document.write content will not be added to the page at all.

c)

It will remove all content and code that was previously on the page and render only the document.write content.

d)

It will append the document.write content to the beginning of the page without overwriting the existing page content.

10.

Which method dynamically modifies the value of an element's attribute?

a)

setAttribute

b)

getAttribute

c)

removeAttribute

d)

getElementById

11.

What two parameters does the setAttribute() method take?


3.1: Modify HTML with JavaScript.

a)

The name and the id of the attribute to retrieve

b)

The name of the attribute to set and its new value

c)

The name of the element and the attribute to set

d)

The name of the attribute to remove and its replacement attribute

12.

Which of the following protocols is used to protect the user data during transmission?

a)

SSL

b)

SSH

c)

IPsec

d)

HTTPS

13.

Which property of the form object returns the number of elements in the form?

a)

target

b)

encoding

c)

elements

d)

length

14.

Which of the following methods of an HTML form object removes focus from an input element?

a)

autofocus()

b)

focus()

c)

blur()

d)

remove()

15.

Which two objects are not supported on the Safari browser?

a)

email and URL

b)

email and search

c)

email

d)

color and URL

16.

Which example shows proper JavaScript syntax for referring to a form object named newForm having a text box named fieldName?

a)

form.newForm.fieldName."value"

b)

document.newForm[fieldName].value;

c)

document.newForm.fieldName.value;

d)

window.newForm.fieldName.value;

17.

Which of the following should be done while adding validation to a form?

a)

Test multiple fields in one validation.

b)

Test the form validation on a single browser.

c)

Validations should not override each other.

d)

Alert messages should be discursive.

18.

Which event handler of the select object specifies the JavaScript code to execute when a user moves the cursor to the select list?

a)

onsubmit

b)

onblur

c)

onchange

d)

onfocus

19.

Which property is not supported by the hidden object?

a)

autofocus

b)

type

c)

value

d)

name

20.

In JavaScript, what is the purpose of the form object?

a)

To access all properties of a form

b)

To replace the HTML <form> tags

c)

To enclose the HTML <form> tags

d)

To represent all the forms in a single Website

21.

Which property is not supported by the hidden object?

a)

autofocus

b)

type

c)

value

d)

name