Week 6 Flashcards
DOM stands for _________ _______ ______, it is a data structure that represents all parts of an ____ document
Document Object Model, HTML
The JavaScript object “document” represents the entire ___
DOM
T/F - DOM methods allow programmatic access to the tree
True
A node is an ______ that has properties. Each node in the DOM tree has:
A ____
A________ and their values
C_____ (if any)
object, A name, Attributes, Content
Types of DOM nodes (3)
Element Nodes, text nodes, attribute nodes
Properties of a basic node object:
(hint) 4 parent child related
Childnodes, firstChild, lastChild, parentNode
nodeName, nodeType, nodeValue, textContent
5 Selection methods
get______By__
get_______By_______
get_______ByC________
q___________(________)
q_____________(________)
getElementById(“id”)
getElementsByClassName(“name”)
getElementsByTagName(“name”)
querySelector(“selector”)
querySelectorAll(selector)
Explain this
getElementById(“id”)
returns the DOM node whose id matches the methods parameter
getElementsByClassName(“name”)
returns an array containing all the DOM nodes whose class attribute matches the methods parameter
getElementsByTagName(“name”)
Returns an array of all the DOM nodes whose type is the same as the methods parameter
getElementsByTagName(“footer”)
QuerySelectorAll()
Returns an array containing ALL the DOM nodes that match the CSS selector in the methods parameter
QuerySelector()
Returns the first element found in the DOM that matches the CSS selector in the methods parameter
A manipulation method ______s the right element from the DOM and then it will ______ the right property of this element
Select, change
Manipulation methods - Create Node:
Insert and removal:
node._______(_____ __ ______) - Insert into node at the beginning
node.before(nodes or strings) - Insert right before node
node._____(nodes or strings) - Insert right after node
____._____(nodes or strings) - Add the new node to the existing DOM tree
____.______() - remove nodes
node.prepend(nodes or strings)
node.before(nodes or strings)
node.after(nodes or strings)
node.append(nodes or strings)
node.remove()
Commonly used node properties:
Her definitions:
innerHTML -
textContent -
style -
innerHTML - all of the content of an element (text and tags). It replaces content but retains attributes
textContent - gets the content of all elements
style - They style attribute of the element
Better context:
InnerHTML - Can be used to get/set the content of the element it is used on. Whatever is inside is replaced but attributes are retained.