Created
May 9, 2020 09:29
-
-
Save holocc/3aa051625f2e3a7dae7d92db86aeedd2 to your computer and use it in GitHub Desktop.
点击穿透
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<style type="text/css"> | |
.button { | |
background: red; | |
height: 300px; | |
} | |
.wrapper { | |
position: absolute; | |
top: 0; | |
bottom: 0; | |
left: 0; | |
right: 0; | |
background: blue; | |
opacity: .5; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="wrapper"> | |
</div> | |
<div class="button">click me</div> | |
</body> | |
<script> | |
function addEvent (name, target) { | |
target = target || document.body | |
target.addEventListener(name, function () { | |
console.log(target, name) | |
}) | |
} | |
const wrapper = document.querySelector('.wrapper') | |
const button = document.querySelector('.button') | |
wrapper.addEventListener('touchstart', function () { | |
document.body.removeChild(wrapper) | |
}) | |
button.addEventListener('click', function () { | |
console.log('button click') | |
}) | |
// addEvent('touchstart') | |
// addEvent('click') | |
// addEvent('touchend') | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment