Week 5, Day 1: So Manipulative!
(Demos originally created by Kate Hollenbach.)
document.getElementById()
: find element on page by ID
document.querySelector()
: find first element on page with selector
document.querySelectorAll()
: find all elements on the page matching the selector, as an array
Simple mouse interaction with the onclick attribute
Update a variable on click
Conditionally update a variable on click
Click button to add an element to the page
Styled button
Respond to click with addEventListener
Add element at click location
Scroll event with sticky position
Delay, automate, and repeat actions with setTimeout or setInterval
Wares Sample Code