LearningFuze Mod 1 - Dom Query Flashcards
(40 cards)
Why do we log things to the console?
To check and debug our code
What is a “model”?
Its showing an example of something
Which “document” is being referred to in the phrase Document Object Model?
Document Node
What is the word “object” referring to in the phrase Document Object Model?
A collection of objects in javascript
What is a DOM Tree?
It represents html objects in the nodes
Give two examples of document methods that retrieve a single element from the DOM.
Documents query selector, and get element by ID
Give one example of a document method that retrieves multiple elements from the DOM at once.
getElementsByClassName()
Why might you want to assign the return value of a DOM query to a variable?
When you need to work with an element more than once, you should use a variable for that query, it also saves time
What console method allows you to inspect the properties of a DOM element object?
the dir method
Why would a tag need to be placed at the bottom of the HTML content instead of at the top?
The HTML must be read before the script, or the webpage will read the script first
What does document.querySelector() take as its argument and what does it return?
It takes a CSS selector but instead of a string it returns the HTML element and what it’s holding
What does document.querySelectorAll() take as its argument and what does it return?
it takes any CSS selector and it returns a static Node list
Why do we log things to the console?
To check and debug our code
What is the purpose of events and event handling?
An event indicates an action taking place, and the event handle deals with the event
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?
the addEventListener method
What is a callback function?
it calls and argument in another function
What object is passed into an event listener callback when the event fires?
the event object
What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?
It is the element that targets the event
What is the difference between these two snippets of code?
element. addEventListener(‘click’, handleClick)
element. addEventListener(‘click’, handleClick())
The first code has the callback function and the second code is just being called.
What is the className property of element objects?
Is a property that allows us to access or set value of the class for that element
How do you update the CSS class attribute of an element using JavaScript?
using the className property
What is the textContent property of element objects?
Allows you to update the text content of the element you are working with
How do you update the text within an element using JavaScript?
Inner html or text content