Using JavaScript in HTML

Learn how to add JavaScript to make web pages interactive.

Back to Home

Step 1: Learn the Basics

JavaScript is used to make web pages interactive. Example:

<button onclick="showMessage()">Click Me</button>
<p id="message"></p>

<script>
    function showMessage() {
        document.getElementById("message").innerHTML = "Hello, World!";
    }
</script>

Step 2: Try It Yourself

Create a button that, when clicked, changes the text inside a paragraph.