-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path05-events.html
More file actions
76 lines (61 loc) · 1.83 KB
/
05-events.html
File metadata and controls
76 lines (61 loc) · 1.83 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Events</title>
<style>
#parent {
width: 300px;
background-color: whitesmoke;
display: flex;
flex-direction: column;
gap: 10px;
padding: 10px;
border-radius: 6px;
}
.child {
padding: 4px;
background-color: white;
}
#textBox {
border: 1px solid gray;
outline: none;
width: 300px;
border-radius: 6px;
padding: 5px;
margin-top: 20px;
}
#textBox:focus {
border: 1px solid dodgerblue;
}
</style>
</head>
<body>
<h2>Point someone for making tea.</h2>
<div id="parent">
<div class="child">Arham</div>
<div class="child">Salman</div>
<div class="child">Mehwish</div>
</div>
<input id="textBox" type="text" placeholder="Type Something...">
<p id="result"></p>
<script>
let parent = document.getElementById("parent");
let result = document.getElementById("result");
let textBox = document.getElementById("textBox");
parent.addEventListener("click", function(e) {
result.innerHTML = "You pointed " + e.target.textContent + " for making tea.";
});
textBox.onkeydown = function(e) {
result.innerHTML = "Your " + e.key + " is down.";
}
textBox.onkeyup = function(e) {
result.innerHTML = "Your " + e.key + " is up.";
}
// textBox.onkeypress = function(e) {
// result.innerHTML = "Your " + e.key + " is pressed.";
// }
</script>
</body>
</html>