<!DOCTYPE html>
<html>
<head>
    <title>JavaScript Example</title>
    <script>
        // JavaScript code
        function greet() {
            var name = document.getElementById("nameInput").value;
            var greeting = "Hello, " + name + "!";
            document.getElementById("output").textContent = greeting;
        }
    </script>
</head>
<body>
    <h1>JavaScript Example</h1>
    <label for="nameInput">Enter your name:</label>
    <input type="text" id="nameInput">
    <button onclick="greet()">Greet</button>
    <p id="output"></p>
</body>
</html>