-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsclick.html
56 lines (47 loc) · 1.3 KB
/
jsclick.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Events Example</title>
<style>
#myDiv {
width: 200px;
height: 100px;
border: 1px solid #000;
margin: 20px;
text-align: center;
line-height: 100px;
cursor: pointer;
}
</style>
</head>
<body>
<div id="myDiv" onclick="onClickEvent()" onabort="onAbortEvent()" onload="onLoadEvent()" onmouseover="onMouseOverEvent()" onmouseout="onMouseOutEvent()" onchange="onChangeEvent()" onerror="onErrorEvent()">
Click me!
</div>
<script>
function onClickEvent() {
alert("Click event triggered!");
}
function onAbortEvent() {
alert("Abort event triggered!");
}
function onLoadEvent() {
alert("Load event triggered!");
}
function onMouseOverEvent() {
document.getElementById("myDiv").style.backgroundColor = "#e0e0e0";
}
function onMouseOutEvent() {
document.getElementById("myDiv").style.backgroundColor = "";
}
function onChangeEvent() {
alert("Change event triggered!");
}
function onErrorEvent() {
alert("Error event triggered!");
}
</script>
</body>
</html>