Quiz: The Document Object Model
Try this self-check quiz to test your knowledge!
The Document Object Model (DOM) is a hierarchy that most closely resembles what object?
Every node in the DOM represents what?
What three relationships between nodes are key to the DOM hierarchy?
Which method selects the first matching element in the document?
document.querySelectorAll()
document.getElementsByClass()
document.querySelector()
document.getElementsByTagName()
document.querySelector()
method returns the first matching DOM element.Which command creates a new button?
let button = document.new('button');
let button = document.createElement('');
let button = document.createElement('button');
let button = document.makeElement('{button}');
let button = document.createElement('button');
command creates a new button.Which command adds the we just created to the DOM?
document.body.appendChild(button);
document.insert(button);
window.appendChild(button);
document.insertBefore(button);
document.body.appendChild(button);
command appends the button to the body
of the document.What can we accomplish by modifying a DOM element's innerHTML
attribute?
innerHTML
.What method allows us to add an attribute to a DOM element?
element.getAttribute()
element.createAttribute()
element.setAttribute()
element.makeAttribute()
element.setAttribute()
method is used to create a new attribute on a DOM element (and also to alter an existing attribute).Which are valid CSS property names in JavaScript?
fontFamily
background-position
marginTop
font-weight
background
What does the window.getComputedStyle()
method return?
style
object with all of the CSS properties affecting the visual display of the DOM element (including those inherited from parent elements).properties
object with some of the CSS properties affecting the visual display of the DOM element.style
object with only the CSS properties defined explicitly for the DOM element.window.getComputedStyle()
method returns a style
object with all of the CSS properties affecting the visual display of the DOM element (including those inherited from parent elements).What prefix indicates that an HTML attribute is intended to store information for computing?
info-
db-
data-
query-
param-
data-
prefix indicates that an HTML attribute is intended to store information for computing.How can we access the data attributes of an HTML element from within JavaScript?
element.getData()
element.dataset
element.getAttribute()
element.db
element.fetchData()
element.dataset
object.Visit Quiz Online
The quiz on this page has been removed from your PDF or ebook format. You may take the quiz by visiting this book online.