Skip to content

Commit

Permalink
👂 Event handling
Browse files Browse the repository at this point in the history
  • Loading branch information
404reese committed Sep 26, 2024
1 parent 0db84eb commit 8046994
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
18 changes: 18 additions & 0 deletions DOM/dom2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- addEventListener -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>addEventListener</title>
</head>
<body>
<button id="btn">Click Me!</button>
<button>1</button>
<script>
document.getElementById('btn').addEventListener('click', function(){
alert('button was clicked');
})
</script>
</body>
</html>
19 changes: 19 additions & 0 deletions DOM/dom2a.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>addEventListener</title>
</head>
<body>
<p id="textParagraph">Original text goes here.</p>
<button id="changeTextButton">Change Text</button>

<script>
document.getElementById('changeTextButton').addEventListener('click', function() {
const paragraph = document.getElementById('textParagraph');
paragraph.textContent = 'The text has been changed!';
});
</script>
</body>
</html>

0 comments on commit 8046994

Please sign in to comment.