Skip to content

Instantly share code, notes, and snippets.

@shaomingquan
Created March 25, 2019 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaomingquan/a1d383d4e87f332fe2d3f2aeb29222b3 to your computer and use it in GitHub Desktop.
Save shaomingquan/a1d383d4e87f332fe2d3f2aeb29222b3 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
#a {
height: 300px;
width: 300px;
background-color: #eee;
}
#b {
height: 200px;
width: 200px;
background-color: #ccc;
}
#c {
height: 100px;
width: 100px;
background-color: #bbb;
}
</style>
</head>
<body>
<div id="a">
<div id="b">
<div id="c"></div>
</div>
</div>
</body>
<script>
var a = document.getElementById('a')
var b = document.getElementById('b')
var c = document.getElementById('c')
const useCaptrue = true
a.addEventListener('click', function (e) {
console.log('a', e.path.length)
}, useCaptrue)
b.addEventListener('click', function (e) {
console.log('b', e.path.length)
}, useCaptrue)
c.addEventListener('click', function (e) {
console.log('c', e.path.length)
}, useCaptrue)
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment