DOM Flashcards
why do we log things to the console?
to examine if the browser is showing the right value
what is a “model”?
representation of the objects (replica)
which “document” is being referred to in the phrase Document Object Model?
web page that can be displayed in the browser window or as the html source.
what is the word “object” referring to in the phrase Document Object Model?
- data type object in javascript
- DOM is javascript object which is a model of the html document
- it is not your html document. it is a response for your html document
what is a DOM Tree?
The DOM represents a document with a logical tree. Each branch of the tree ends in a node, and each node contains objects.
parent elements containing child elements with nodes.
Give two examples of document methods that retrieve a single element from the DOM.
getElementById,
querySelector (only use this) - for consistency
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?
store the info that you need and access to it again
what console method allows you to inspect the properties of a DOM element object?
dir
why would a tag need to be placed at the bottom of the html content instead of at the top?
to load the html and css first, and then javascript to be loaded
what does document.querySelector() take as its argument and what does it return?
string of the css selector and returns the first one of the matching elements.
what does document.querySelectorAll() take as its argument and what does it run?
css selector and returns a NodeList (collection of data that matches the element and can’t add items)
what is the purpose of events and event handling? -> interactive web apps
Events are actions or occurrences that happen in the system you are programming, which the system tells you about so your code can react to them.
To react to an event, you attach an event handler to it. This is a block of code (usually a JavaScript function that you as a programmer create) that runs when the event fires.
When such a block of code is defined to run in response to an event, we say we are registering an event handler
Are all possible parameters required to use a JavaScript method or function?
no. can call a function without a parameter.
what method of element objects lets you set up a function to be called when a specific type of event occurs?
addEvenListener