DOM Flashcards
(43 cards)
Why do we log things to the console?
to check the result of element
What is a “model”?
representation of an actual thing
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?
JavaScript
What is a DOM Tree?
tree data structure of HTML page
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.
querySelectorAll
Why might you want to assign the return value of a DOM query to a variable?
to reuse the result again
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?
so that dom element gets loaded before javascript try to get elements
What does document.querySelector() take as its argument and what does it return?
selector element and result first match
What does document.querySelectorAll() take as its argument and what does it return?
selector element and result is all-match
Why do we log things to the console?
to debugging
What is the purpose of events and event handling?
to perform some action base on user action
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
What is the className property of element objects?
its use to get and update class name of element
How do you update the CSS class attribute of an element using JavaScript?
get element using className
What is the textContent property of element objects?
It can get or update the element text content
How do you update the text within an element using JavaScript?
using element.textContetent = value
is the event parameter of an event listener callback always useful?
No
Would this assignment be simpler or more complicated if we didn’t use a variable to keep track of the number of clicks?
more complicated
Why is storing information about a program in variables better than only storing it in the DOM?
to get specific element property multiple time and going through dom each time is not effective its better to store it to the variable
Does the document.createElement() method insert a new element into the page?
no it does not