Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
.button {
background: red;
height: 300px;
.wrapper {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: blue;
opacity: .5;
<div class="wrapper">
<div class="button">click me</div>
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 () {
button.addEventListener('click', function () {
console.log('button click')
// addEvent('touchstart')
// addEvent('click')
// addEvent('touchend')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.