JS Flashcards
What is the className property of element objects?
Property holding the class attribute of that element
How do you update the CSS class attribute of an element using JavaScript?
object name.class name
What is the textContent property of element objects?
The text containing the element and it’s children
How do you update the text within an element using JavaScript?
objectname.text content
Is the event parameter of an event listener callback always useful?
not always
Would this assignment be simpler or more complicated if we didn’t use a variable to keep track of the number of clicks?
more difficult
Why is storing information about a program in variables better than only storing it in the DOM?
it’s more work for the browser
Why do we log things to the console?
to check for errors
What is the purpose of events and event handling?
so that developers would scan response
What do [] square brackets mean in function and method syntax documentation?
denotes that it’s optional can be provided or not
What method of element objects lets you set up a function to be called when a specific type of event occurs?
add event listener
What is a callback function?
function within a function
What object is passed into an event listener callback when the event fires?
a huge object when the event is passed containing all the info
What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?
element target which event originated from
What is a “model”?
a represenation of something
Which “document” is being referred to in the phrase Document Object Model?
html document
What is the word “object” referring to in the phrase Document Object Model?
objects in js
What is a DOM Tree?
map representing all elements and its children
Give two examples of document methods that retrieve a single element from the DOM.
query selector to get element by id
Give one example of a document method that retrieves multiple elements from the DOM at once.
query selector all
Why might you want to assign the return value of a DOM query to a variable?
store the location of the element
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?
allows html elements to load first
What does document.querySelector() take as its argument and what does it return?
element, class, id
What does document.querySelectorAll() take as its argument and what does it return?
css selector, string, returns a node list