summaryrefslogtreecommitdiff
path: root/javascript/02-button-click/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'javascript/02-button-click/index.html')
-rw-r--r--javascript/02-button-click/index.html25
1 files changed, 25 insertions, 0 deletions
diff --git a/javascript/02-button-click/index.html b/javascript/02-button-click/index.html
new file mode 100644
index 0000000..335d7d9
--- /dev/null
+++ b/javascript/02-button-click/index.html
@@ -0,0 +1,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>