Fictional student demo · Ada Okafor · Changes reset when you leave.
My Learning
AO
Back to programme

JavaScript & DOM

Make a page respond to a click

A web page becomes interactive when JavaScript responds to something a person does. Start by finding an element on your page. Then listen for a click. const button = document.querySelector("button"); button.addEventListener("click", () => { button.textContent = "You did it!"; }); Try it yourself Create a button that changes a heading when clicked. Give the button a clear label. Test that it works with both a mouse and your keyboard. Think about it What should happen if the button is clicked a second time?

Your notes

Resources

No additional resources.