TutorialPedia.org
Toggle Menu
Home
Online Go Compiler
Tutorials
JavaScript Tutorials
Golang Tutorials
Linux Command Line Tutorials
Blog
All Posts
JavaScript DOM Manipulation
Practice working with the DOM,events,and browser APIs.
1. Which method is used to select an element by its unique ID?
getElementById
querySelector
getElementsByClassName
getElementsByTagName
2. Select all common DOM event types.
click
submit
load
alert
3. document.querySelector('#header') returns the first element with the id 'header'.
True
False
4. What does the acronym DOM stand for?
5. Which property sets/returns the text content of an element without interpreting HTML?
innerHTML
textContent
value
text
6. Which methods can add a CSS class to an element?
classList.add('active')
className += ' active'
setAttribute('class', 'existing active')
removeAttribute('class')
7. The appendChild() method inserts a new child element at the beginning of the parent's child nodes.
True
False
8. What method creates a new DOM element (e.g., <div>)?
9. Which method allows registering multiple event handlers for the same event on an element?
addEventListener('click', handler)
onclick = handler
attachEvent('onclick', handler)
onload = handler
10. Which properties return the parent node of an element?
parentNode
parentElement
closest('.container')
previousSibling
Reset
Answered 0 of 0 — 0 correct