wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript DOM Sec A

Total questions: 20

Worksheet time: 7mins

Name
Class
Date
1.
What does DOM stand for?
a)
Data Object Model
b)
Dynamic Object Manipulation
c)
Document Object Model
d)
Document Order Manipulation
2.
Which method is used to access an HTML element by its ID?
a)
getElementById()
b)
selectElement()
c)
findElement()
d)
querySelector()
3.
How do you change the content of an HTML element using JavaScript?
a)
textContent
b)
innerHTML
c)
innerText
d)
contentText
4.
What does the document.write() method do in JavaScript?
a)
Writes HTML expressions or JavaScript code to a document
b)
Opens a new document
c)
Deletes the current document
d)
Appends text to an existing document
5.
What will the following code output? console.log(5 + '5');
a)
10
b)
'55'
c)
55
d)
Error
6.
What is the result of the following expression? typeof(undefined);
a)
'string'
b)
'null'
c)
'object'
d)
'undefined'
7.
What will the following code output? console.log(typeof NaN);
a)
'NaN'
b)
'null'
c)
'undefined'
d)
'number'
8.
What will be the output of the following code? console.log(3 < 2 < 1);
a)
True
b)
False
c)
null
d)
Error
9.
What will be the output of the following code? console.log([] == ![]);
a)
Error
b)
null
c)
True
10.
Which of the following JavaScript conditions can be used to remove the vowel 'a' from a string?
a)
a !== 'a'
b)
a !== 'e'
c)
a !== 'i'
d)
a !== 'o'
11.
Which event fires when the user clicks on an HTML element?
a)
click
b)
onMouseClick
c)
onClick
d)
mouseClick
12.
How can you add a new element to the DOM?
a)
newElement()
b)
appendChild()
c)
addElement()
d)
insertElement()
13.
Which method removes a child node from the DOM?
a)
deleteChild()
b)
deleteNode()
c)
removeNode()
d)
removeChild()
14.
What does querySelector() return when the specified selector matches no elements?
a)
An empty array
b)
null
c)
An empty object
d)
undefined
15.
What does the `addEventListener` method's third argument 'useCapture' specify?
a)
The priority of the event listener
b)
The number of times the event listener should be invoked
c)
Whether the event should be captured or bubbled
d)
The priority of the event listener
16.
Which method is used to get the value of a specified attribute from an element?
a)
getProperty()
b)
getProp()
c)
getAttributeValue()
d)
getAttribute()
17.
What method can be used to create a new element in the DOM?
a)
createNewElement()
b)
newElement()
c)
createElement()
d)
addElement()
18.
How can you remove an event listener from an element?
a)
deleteEventListener()
b)
removeEventListener()
c)
detachEvent()
d)
removeEvent()
19.
What method is used to update the content of an HTML element?
a)
updateContent()
b)
innerHTML
c)
setContent()
d)
setText()
20.
How do you remove an element from the DOM?
a)
removeElement()
b)
delete()
c)
remove()
d)
destroy()