128 DOM-Manipulation PDF
128 DOM-Manipulation PDF
DOM
MAKE SURE YOU ARE
COMFORTABLE WITH
BASIC HTML & CSS!
DOCUMENT
OBJECT
M ODEL
WHAT IS IT?
The DOM is a JavaScript
representation of a
webpage.
It's your JS "window" into
the contents of a webpage
It's just a bunch of
objects that you can
interact with via JS.
HTML+CSS Go In... JS Objects Come Out
I'm an
object!
DOCU
MENT
BODY
Me too!
H1 UL
LI LI
D
O
OCUMENT
BJECT I have nothing to do
with the DOM but I
M ODEL
look cool!
DOCU
MENT
DOCUMENT
The document object is our entry
BODY
classList innerText
getAttribute() textContent
setAttribute() innerHTML
appendChild() value
append() parentElement
prepend() children
removeChild() nextSibling
remove() previousSibling
createElement style
EVENTS
Responding to user
inputs and actions!
A SMALL TASTE
clicks mouse wheel
drags double click
drops
copying
hovers
pasting
scrolls
form submission audio start
key presses screen resize
focus/blur printing
addEventListener
Specify the event type and a callback to run