-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path36. Events in Javascript.html
75 lines (62 loc) · 2.69 KB
/
36. Events in Javascript.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
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body style="background-color: black; color: white;">
<h2>Amazing image</h2>
<div>
<ul id="images">
<li><img width="200px" id="photoshop"
src="https://images.pexels.com/photos/3561339/pexels-photo-3561339.jpeg?auto=compress&cs=tinysrgb&w=1600&lazy=load"
alt="photoshop"></li>
<li><img width="200px" id="japan"
src="https://images.pexels.com/photos/3532553/pexels-photo-3532553.jpeg?auto=compress&cs=tinysrgb&w=1600&lazy=load"
alt=""></li>
<li><img width="200px" id="river"
src="https://images.pexels.com/photos/3532551/pexels-photo-3532551.jpeg?auto=compress&cs=tinysrgb&w=1600&lazy=load"
alt=""></li>
<li><img width="200px" id="owl"
src="https://images.pexels.com/photos/3532552/pexels-photo-3532552.jpeg?auto=compress&cs=tinysrgb&w=1600&lazy=load"
alt=""></li>
<li><img width="200px" id="prayer"
src="https://images.pexels.com/photos/2522671/pexels-photo-2522671.jpeg?auto=compress&cs=tinysrgb&w=1600&lazy=load"
alt=""></li>
<li><a style="color: aliceblue;" href="https://google.com" id="google">Google</a></li>
</ul>
</div>
</body>
<script>
document.getElementById("images").addEventListener("click", function (e) {
// console.log("Clicked");
}, false)
document.querySelector("#owl").addEventListener("click", function (e) {
// console.log("Owl clicked");
// e.stopPropagation();
alert("Owl clicked");
}, false);
document.querySelector("#google").addEventListener("click", function (e) {
// console.log("Google clicked");
e.preventDefault();
// e.stopPropagation();
}, false)
document.querySelector("#images").addEventListener("click", function (e) {
// console.log(e.target.tagName); // IMG
// console.log(e.target.parentNode);
// console.log(e.target.id);
// if (e.target.tagName === 'IMG') {
// console.log(e.target.id);
// }
// let removeIt = e.target.parentNode;
// removeIt.remove();
}, false)
</script>
</html>
<!-- // let removeIt = e.target.parentNode; -->
<!-- //removeIt.parentNode.removeChild(removeIt); -->
<!-- // type, timestamp, defaultPrevented
// target, toElement, srcElement, currentTarget,
// clientX, clientY, screenX, screenY
// altkey, ctrlkey, shiftkey, keyCode -->