Repository navigation
Expand file tree
/
Copy pathbubble.html
More file actions
53 lines (52 loc) · 1.65 KB
/
Copy pathbubble.html
File metadata and controls
53 lines (52 loc) · 1.65 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Event Bubble</title>
<style>
ul{
border: 2px solid tomato;
margin: 20px;
}
body{
color: green;
border: 2px salmon solid;
}
section{
border: 2px solid blue;
margin: 20px;
}
</style>
</head>
<body id="body">
<h1>Exploring Event Bubble</h1>
<section id="list-container">
<ul id="list-ul">
<li id="item-1">Lorem, ipsum.</li>
<li id="item-2">Iure, nulla.</li>
<li id="item-3">Eveniet, dicta?</li>
<li id="item-4">Deserunt, libero.</li>
<li id="item-5">Dignissimos, ad.</li>
<li id="item-6">Suscipit, placeat?</li>
</ul>
</section>
<script>
document.getElementById('item-2').addEventListener('click', function(event){
console.log('Item 2 Clicked');
//event.stopPropagation();
event.stopImmediatePropagation();
});
document.getElementById('list-ul').addEventListener('click', function(){
console.log('Ul Clicked');
});
document.getElementById('list-container').addEventListener('click', function(){
console.log('Section Container Clicked');
});
document.getElementById('body').addEventListener('click', function(){
console.log('Body of the HTML Clicked');
});
</script>
</body>
</html>