DOM Flashcards
Why do we log things to the console?
to check and see if our output is what we expected.
What is a “model”?
the structure of a web page.
Which “document” is being referred to in the phrase Document Object Model?
html.
What is the word “object” referring to in the phrase Document Object Model?
Data type object that can hold multiple values.
What is a DOM Tree?
a model of a page. JavaScript object model of the html document. not the original, representation of the original. DOM is not html doc. JavaScript object recreating html document. javascript object for html element, including all of its attributes values and children’s attributes and values..
Give two examples of document methods that retrieve a single element from the DOM.
querySelector, getElementById
Give one example of a document method that retrieves multiple elements from the DOM at once.
getElementsByClassName, getElementsByTagName, querySelectorAll
Why might you want to assign the return value of a DOM query to a variable?
so that you can access it and reuse it later.
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?
you need the html document to load first before JavaScript does.
What does document.querySelector take as its argument and what does it return?
takes string that contains css selector as argument and returns the first of the matching elements.
What does document.querySelectorAll take as its argument and what does it return?
takes string that contains css selector as argument and returns all of the elements that match as NodeList.
Why do we log things to the console?
to check our work and see if the output is the result anticipated.
What is the purpose of events and event handling?
events occur based on user interaction and makes website more interactive. Event handlers specify the type of user interaction. create a reaction, do that reaction in response to something happening. for interactivity in web applications.
Are all possible parameters required to use a JavaScript method or function?
no. for instance, the splice method does not require new items to add in.
What method of element objects lets you set up a function to be called when a specific type of event occurs?
addEventListener of element objects.