-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
63 lines (59 loc) · 1.96 KB
/
index.html
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DOM - Index</title>
<style>
.color-box{
background-color: limegreen;
width: 100px;
height: 100px;
}
</style>
</head>
<body>
<!-- <button class="event-button">Click me!</button>
<script>
const button = document.querySelector('.event-button');
button.addEventListener('click', function() {
alert("Hey There!");
});
</script> -->
<!-- <input placeholder="type into me!" class="input-to-copy" />
<p class="p-to-copy-to">Nothing has happened yet.</p>
<script>
const input = document.querySelector(".input-to-copy");
const paragraph = document.querySelector(".p-to-copy-to");
// there is also keydown which will miss the last one character
input.addEventListener("keyup", function() {
paragraph.innerText = input.value;
});
</script> -->
<!-- <div class="color-box"></div>
<input placeholder="type a color here" class="color-input">
<script>
const input = document.querySelector(".color-input");
const paragraph = document.querySelector(".color-box");
input.addEventListener("change", function() {
paragraph.style.backgroundColor = input.value;
})
</script> -->
<!-- Event Delegation -->
<div class="button-container">
<button>1</button>
<button>2</button>
<button>3</button>
<button>4</button>
<button>5</button>
</div>
<script>
document.querySelector(".button-container").addEventListener("click", function(event) {
if (event.target.tagName === "BUTTON") {
alert(`You clicked on button ${event.target.innerText}`);
event.target.innerText = "CLICKED";
}
})
</script>
</body>
</html>