Intro to JavaScript in HTML quiz

Quiz
•
Computers
•
9th - 12th Grade
•
Hard
Belinda Bell
Used 2+ times
FREE Resource
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment:
Which of the following code segments would successfully access the list item with the id “list-one”?
A. document.getElementById("list-one");
B. document.getElementsByTagName("li")[1];
C. document.getElementsByTagName("ul")[0].firstElementChild;
A only
A and B only
A and C only
A, B and C
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment:
A programmer stores the ul tags in a list:
var list = document.getElementsByTagName("ul");
Which of the following code segments would successfully append the element newListItem as the first child in the ul element?
list.appendChild(newListItem);
list[0].appendChild(newListItem);
list[0].insertBefore(document.getElementById("list-one"), newListItem);
list[0].insertBefore(newListItem, document.getElementById("list-one"));
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
A programmer creates a new div:
var image = document.createElement("img");
Which of the following lines of code will correctly assign this element the image “kitten.jpg”?
image.setAttribute("src", "kitten.jpg");
image.setAttribute("kitten.jpg", "src");
image.setAttribute("href", "kitten.jpg");
image.setAttribute("kitten.jpg", "href");
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
A programmer wants to create a function that turns the color of any element clicked to red. They write the function:
But when they try to run it, the div doesn’t turn red. How can they fix their function so that it works correctly with the event listener?
Add a parameter element so they element being called can be passed to the function.
Add a parameter this so they element being called can be passed to the function.
Change element.setAttribute to this.setAttribute.
background-color should be written backgroundColor.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
A programmer wants to create a function that alerts the user they clicked a button. They write the function:
function buttonAlert() {
alert("You clicked a button!");
}
How can this programmer add this as an inline style to a button element?
<button onclick = "buttonAlert"></button>
<button onclick = "buttonAlert()"></button>
<button click = "buttonAlert"></button>
<button click = "buttonAlert()"></button>
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Assuming that both elements started at the x-coordinate 0 on the webpage, how many pixels has the element with the id “outer” moved along the x axis?
5 pixels
10 pixels
-5 pixels
0 pixels
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
Kuizi 13 - Web

Quiz
•
10th Grade - University
20 questions
UH-INFO-1

Quiz
•
11th Grade
20 questions
La sintassi CSS

Quiz
•
9th Grade - Professio...
22 questions
Keyboard and Mouse Input

Quiz
•
9th - 12th Grade
18 questions
Graphics

Quiz
•
1st - 12th Grade
20 questions
UID uCertify Chapter 9 Test

Quiz
•
8th - 12th Grade
18 questions
Data Representation

Quiz
•
4th - 11th Grade
22 questions
Basics of App Coding

Quiz
•
8th - 12th Grade
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
10 questions
1.2 OSI & TCP IP Models Quiz

Quiz
•
10th Grade
20 questions
Digital Citizenship

Quiz
•
8th - 12th Grade
30 questions
Introduction to Computers

Quiz
•
8th - 9th Grade
35 questions
Computer Baseline Examination 2025-26

Quiz
•
9th - 12th Grade
13 questions
Problem Solving Process

Quiz
•
9th - 12th Grade
20 questions
Hardware vs. Software Quiz

Quiz
•
7th - 10th Grade
10 questions
Understanding Algorithms with Pseudocode and Flowcharts

Interactive video
•
9th - 12th Grade