W3Tutorials.net
Toggle Menu
Home
Online Go Compiler
Tutorials
Javascript Tutorials
Python Tutorials
Go Tutorials
Blog
All Posts
JavaScript DOM Manipulation
Check your ability to use DOM APIs to modify web pages.
1. Which method is used to select a DOM element by its 'id' attribute?
getElementById()
querySelector()
getElementsByClassName()
getElementsByTagName()
2. Which of the following DOM methods return a live HTMLCollection?
getElementsByClassName()
querySelectorAll()
getElementsByTagName()
getElementById()
3. The textContent property parses HTML tags when setting an element's content.
True
False
4. What method is used to create a new DOM element (e.g., a <div>)?
5. Which property modifies the text content of an element without parsing HTML?
textContent
innerHTML
outerHTML
innerText
6. Which methods add an event listener to a DOM element?
addEventListener()
onclick property assignment
attachEvent()
removeEventListener()
dispatchEvent()
7. querySelectorAll() returns a live NodeList that updates when the DOM changes.
True
False
8. What method is used to add a CSS class to an element (modern DOM API)?
9. Which method inserts a new node as the first child of a parent element?
prepend()
appendChild()
insertBefore()
insertAfter()
10. Which properties/methods access an element's parent node?
parentNode
parentElement
closest()
children
firstChild
Reset
Answered 0 of 0 — 0 correct