DOM Flashcards
Dom Querying
Why do we log things to the console?
to make sure the script is loading properly, to check for bugs, make sure everything is working smoothly
Dom Querying
What is a ‘model’?
something recreating (representing) something else
Dom Querying
Which ‘document’ is being referred to in the phrase Document Object Model?
html
Dom Querying
What is the word ‘object’ referring to in the phrase Document Object Model?
it’s referring to different parts of the page loaded in the browser window
Dom Querying
What is a DOM Tree?
an element and all of its configurations
Dom Querying
Give two examples of document methods that retrieve a single element from the DOM
getElementById(‘id’)
querySelector(‘css selector’)
Dom Querying
Give one example of a document method that retrieves multiple elements from the DOM at once
querySelectorAll(‘css selector’)
Dom Querying
Why might you want to assign the return value of a DOM query to a variable?
make it easier to use, otherwise you have to write it out every time
Dom Querying
What console method allows you to inspect the properties of a DOM element object?
console.dir()
Dom Querying
Why would a
tag need to be placed at the bottom of the HTML content instead of at the top?
because the browser needs to parse all the elements in the HTML page before Javascript code can access them
Dom Querying
What does document.querySelector() take as its argument and what does it return?
a string containing one or more css selectors
returns: first element that matches the specified selector or group of selectors
Dom Querying
What does document.querySelectorAll() take as its argument and what does it return?
a string containing one or more selectors
returns a static (not live) nodelist containing one element object for each element that matches at least one of the specified selectors or an empty nodelist (not an array) if there isn’t a match
DOM Events:
Why do we log things to the console?
for this exercise, it was to see when the event fires
for debugging
make sure that script is loading properly
DOM Events:
What is the purpose of events and event handling?
so that users can interact with the web page
DOM Events:
Are all possible parameters required to use a JavaScript method or function?
no
DOM Events:
What method of element objects let you set up a function to be called when a specific type of event occurs?
.addEventListener()