Week 4 Reveiw Flashcards
A standardized way to define a web page’s structure
DOM Document Object Model
DOM represents a web page as a _________ of objects
hierarchy
DOM objects have _________ and ___________.
properties methods
__________________ is the langauage of choise for dealing with the DOM
JavaScript
Two types of nodes
elements and texts
The document variable matches the ______ element
HTML
code to visit the child node of a page
document.body.childNodes[0]
child nodes include __________ lines
blank
method to get an element by its HTML tag
getElementsByTagName()
method to get elements by its HTML class
getElementsByClassName()
method to get an element by its ID
getElementById()
to create an array from getElements return use function
Array.from()
method to get the first node with CSS selector
querySelector()
method to get all nodes with CSS selector
querySelectorAll()
property of a node to get its inner HTML content
innerHTML
property of a node that gets the text content
textContent
method to get the attribute of a node
getAttribute()
method to determine if a node has an attribute
hasAttribute()
method to get elements by its HTML tag name attribute
getElementsByTagName()
method to get elements by the class name
getElementsByClassName()
property to change the content of an element within the DOM
innerHTML
use innerHTML to delete content
.innerHTML = “”
add a change to the text of a node
.textContent +=
set a name attribute of a node to “Jeff”
.setAttribute(“name”,”Jeff”)
property used to add or remove classes from a DOM element
classList
3 steps to add a new element to a web page
- create a new Element
- Set element properties
- Inset new element into the DOM