blob: 335d7d901edcab22bbe1fc1f3f147e4b8efb2690 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1 id="heading">Welcome to my page!</h1>
<button id="myButton">Click Me</button>
<script>
// Find the button and the heading on the webpage
const button = document.getElementById("myButton");
const heading = document.getElementById("heading");
// Listen for a click event on the button
button.addEventListener("click", function() {
// Change the text content of the heading
heading.textContent = "Hello from JavaScript!";
});
</script>
</body>
</html>
|