DOM Flashcards
Why do we log things to the console?
To check if the value given was as expected.
What is a “model”?
A representation of something.
Which “document” is being referred to in the phrase Document Object Model?
The HTML document.
What is the word “object” referring to in the phrase Document Object Model?
The data type object in javascript.
What is a DOM Tree?
JS Object for an html element including all of its children plus attributes and values for itself and its children.
Give two examples of document methods that retrieve a single element from the DOM.
querySelector and getElementById.
Give one example of a document method that retrieves multiple elements from the DOM at once.
querySelectorAll
Why might you want to assign the return value of a DOM query to a variable?
To use the same element more than once.
What console method allows you to inspect the properties of a DOM element object?
console.dir( )
Why would a script tag need to be placed at the bottom of the HTML content instead of at the top?
So the browser can parse all of the elements in the page before the javascript code can access them.
What does document.querySelector() take as its argument and what does it return?
Takes a CSS selector as an argument and returns the first element within the document that matches the selector
What does document.querySelectorAll() take as its argument and what does it return?
Takes a CSS selector as an argument and returns a static NodeList representing the documents elements that match the selector.
Why do we log things to the console?
To check if the value given was as expected.
What is the purpose of events and event handling?
To create a reaction for when something occurs on a webpage.
What method of element objects lets you set up a function to be called when a specific type of event occurs?
addEventListener( )