dom querying Flashcards
Why do we log things to the console?
To double check if things are working as intended and deebug our code.
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 elements
What is a DOM Tree?
A visual of a HTML document with all the elements included.
Give two examples of document methods that retrieve a single element from the DOM.
getElementByid(‘id)
querySelector(‘css selector’) - selects the first matching element
Give one example of a document method that retrieves multiple elements from the DOM at once.
getElementsByClassName(‘class’)
getElementsByTagName(‘tagName’)
querySelectorAll(‘css selector’)
Why might you want to assign the return value of a DOM query to a variable?
If you want to locate the node location multiple times, it would be quicker.
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?
The HTML page isn’t rendered only after the Dom is ready
What does document.querySelector() take as its argument and what does it return?
CSS selectors, class, elements, id
returns the first result of the argument
What does document.querySelectorAll() take as its argument and what does it return?
CSS selectors, class, elements, id
returns all arguments matching