Search Header Logo

JavaScript DOM Manipulation Quiz

Authored by Eugene Castro

Computers

8th Grade

Used 1+ times

JavaScript DOM Manipulation Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

25 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What does the following JavaScript code do?

const element = document.getElementById("intro");

Selects the first

element in the document

Selects the element with the id "intro"

Selects all elements with the class "intro"

Selects all

elements inside the element with id "intro"

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What happens if the specified ID does not exist? const element = document.getElementById("missingID");

Returns null

Returns an empty string

Throws an error

Returns an empty object

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which JavaScript method retrieves all paragraph

elements in the document?

document.getElementById("p")

document.getElementsByClassName("p")

document.getElementsByTagName("p")

document.querySelectorAll("#p")

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What will the following code return?

const x = document.getElementsByClassName("intro");

The first element with class "intro"

A collection of all elements with class "intro"

An array of all elements with class "intro"

The last element with class "intro"

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which method selects all paragraph

elements with class "intro"?

document.querySelector("p.intro")

document.getElementsByClassName("intro")

document.querySelectorAll("p.intro")

document.getElementsByTagName("p.intro")

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What does the following code do?

const x = document.getElementById("main");

const y = x.getElementsByTagName("p");

Selects all paragraph

elements inside the element with id "main"

Selects all paragraph

elements in the document

Selects the first paragraph

inside "main"

Throws an error

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which JavaScript code retrieves a form with the name "frm1"?

document.getElementById("frm1")

document.getElementsByTagName("form")

document.forms["frm1"]

document.querySelector("#frm1")

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?