JS dom-querying, events, and manipulation Flashcards
Why do we log things to the console?
to double check our work , inspect value
What is a “model”?
model is a replica of something/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?
object is a datatype in javascript
What is a DOM Tree?
a javascript object for an html element- including all of its elements, attributes and all of its children
Give two examples of document methods that retrieve a single element from the DOM.
document.querySelector(‘element’)
getElementById(‘#idName’)
* can use querySelector for every thing*
Give one example of a document method that retrieves multiple elements from the DOM at once.
querySelectorAll(‘element’)
Why might you want to assign the return value of a DOM query to a variable?
in case you need to access that specific element multiple times
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?
browser needs to inspect entire document before javaScript can access them
What does document.querySelector() take as its argument and what does it return?
takes a string and its css selector- return is the first element it finds that matches that selector
What does document.querySelectorAll() take as its argument and what does it return?
takes a string and its css selector and returns a node list of elements that match that selector
Why do we log things to the console?
to double check our work and inspect values
Are all possible parameters required to use a JavaScript method or function?
no
What method of element objects lets you set up a function to be called when a specific type of event occurs?
addEventListener