DOM Flashcards
What does DOM stand for?
Document Object Model
What is the DOM?
A DOM is a treelike structure that represents the HTML elements on a webpage
Give a DOM example for changing a text value on an HTML window
document.getElementById(“test”).innerHTML = “now it is different”;
document is the root and contains all elements
getElementById followed by the element I am interested in.
innerHTML is the property which I am setting
List 2 common selector methods used by JS for DOM elements
document.querySelector(“#test”)
//this will find the id test
document.querySelectorAll(“test”)
//this will find all elements with id test
What things can be manipulated using DOM?
element properties like
value
innerHTML = “my name”;
CSS
styl.cssText = “fontWeight : bold”;
create a new element
createElement (“this”)
remove an element
remove()