Lesson 5 of 5
Bring your page to life
The <script> tag adds JavaScript: your page can react to clicks.
document.getElementById('id') grabs an element; its content is changed via textContent.
<script>
document.getElementById('magic').onclick = function () {
document.getElementById('message').textContent = 'Welcome!';
};
</script>🎯 Your goal
Add a button id="magic" and an empty paragraph id="message". With JavaScript, on button click, write some text into the paragraph.
index.html
Loading editor…
Preview
Run your code to see your page here.