-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestEvents.html
More file actions
35 lines (34 loc) · 972 Bytes
/
Copy pathtestEvents.html
File metadata and controls
35 lines (34 loc) · 972 Bytes
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test all the events</title>
<script>
window.onload = init;
function init() {
let p = document.getElementById("p");
p.addEventListener("click", handler);
p.addEventListener("resize", handler);
p.addEventListener("play", handler);
p.addEventListener("pause", handler);
p.addEventListener("load", handler);
p.addEventListener("unload", handler);
p.addEventListener("dragstart", handler);
p.addEventListener("drop", handler);
p.addEventListener("mousemove", handler);
p.addEventListener("mouseover", handler);
p.addEventListener("keypress", handler);
p.addEventListener("mouseout", handler);
p.addEventListener("touchstart", handler);
p.addEventListener("touchend", handler);
}
function handler(eventObj) {
let id = eventObj.target.id;
console.log(`Event type: ${ eventObj.type } on ${ id }`);
}
</script>
</head>
<body>
<p id="p">Test</p>
</body>
</html>