HTML
<button id="colorButton">Change box color</button> <div id="box"></div>
JavaScript
let colorButton = document.getElementById(`colorButton`) let box = document.getElementById(`box`) colorButton.addEventListener(`click`, changeBoxColor) function changeBoxColor() { box.innerHTML = `yellow` }
Reason
HTML
<button id="colorButton">Change box color</button> <div id="box"></div>
JavaScript
let colorButton = document.getElementById(`colorButton`) let box = document.getElementById(`box`) colorButton.addEventListener(`click`, changeBoxColor) function changeBoxColor() { box.backgroundColor = `yellow` }
Reason
HTML
<input type="range" min="100" max="400" value="400" id="slider"> <img src="dog.png" id="dog">
JavaScript
let slider = document.getElementById(`slider`) let dog = document.getElementById(`dog`) slider.addEventListener(`input`, resizeDog) function resizeDog() { dog.style.width = `slider.valuepx` }
Reason
HTML
<input type="range" min="100" max="400" value="400" id="slider"> <img src="dog.png" id="dog">
JavaScript
let slider = document.getElementById(`slider`) let dog = document.getElementById(`dog`) slider.addEventListener(`input`, resizeDog) function resizeDog() { dog.style.width = `${slider.value}` }
Reason
HTML
<input type="range" min="100" max="400" value="400" id="slider"> <img src="dog.png" id="dog">
JavaScript
let slider = document.getElementById(`slider`) let dog = document.getElementById(`dog`) slider.addEventListener(`input`, resizeDog) function resizeDog() { dog.style.width = `${slider}px` }
Reason