DOM Flashcards
Why do we log things to the console?
We could determine what the code is doing and help us debug.
What is a “model”?
copy or representation of something
Which “document” is being referred to in the phrase Document Object Model?
HTML document
What is the word “object” referring to in the phrase Document Object Model?
objects in the model that represent a different part of the page loaded in the window and refers to javascript object.
What is a DOM Tree?
layer of how the browser structure the model.
Give two examples of document methods that retrieve a single element from the DOM.
getElementById(‘id’), querySelector(‘css selector’)
Give one example of a document method that retrieves multiple elements from the DOM at once.
getElementByClassName(),
getElementsByTagName(),
querySelectorAll()
Why might you want to assign the return value of a DOM query to a variable?
to store reference or location of an element you’re trying to retrieve into the variable so browser doesn’t have to keep going back to look for the element.
What console method allows you to inspect the properties of a DOM element object?
console.dir()
Why would a tag need to be placed at the bottom of the HTML content instead of at the top?
If the script is at the bottom, the html content can be uploaded first by the browser and then run javascript
What does document.querySelector() take as its argument and what does it return?
takes css selectors as an argument and returns the first matching element.
What does document.querySelectorAll() take as its argument and what does it return?
takes css selectors as an argument and return all the matching elements - nodeList.
Why do we log things to the console?
We log things to check our process and to debug
What is the purpose of events and event handling?
The purpose is to control user input specifically and user interaction by adding dynamic content.
Are all possible parameters required to use a JavaScript method or function?
e
What method of element objects lets you set up a function to be called when a specific type of event occurs?
e