Tutorials

JavaScript Tutorial

All Tutorials Learning Tools Login

JavaScript Tutorial · Chapter 1 of 8

JavaScript Home

Make pages interactive with events and DOM updates.

JavaScript responds to clicks, form submits, and other events.

Try it Yourself loads the HTML, CSS, and JS sample files exactly as shown in the lesson.

JS starter page Try it Yourself »
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JavaScript Tutorial</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <h1>JS Lab</h1>
    <p id="message">Ready to learn JavaScript.</p>
    <button id="helloButton">Say Hello</button>
    <script src="script.js"></script>
</body>
</html>
style.css
body {
    font-family: Arial, sans-serif;
    padding: 32px;
    background: #f8fafc;
}

button {
    padding: 10px 14px;
    border: 0;
    border-radius: 8px;
    background: #0f766e;
    color: white;
}
script.js
document.getElementById("helloButton").addEventListener("click", function () {
    document.getElementById("message").textContent = "Hello from JavaScript!";
});

Classroom Tips

  • Keep script near the end of body or wait for DOM ready.
  • Use the exact sample first, then edit.