console
var test = document.getElementById('test');
var one = document.querySelector('.one');
var two = document.querySelector('.two');
function addEvent(elem, type, showAll) {
type = type.split(' ');
type.forEach(function(item) {
elem.addEventListener(item, function(ev) {
console.log(showAll ? ev: ev.type);
});
});
}
addEvent(one, 'tap click touchstart touchmove touchend touchcancel swipe swipeLeft swipeRight swipeUp swipeDown longTap singleTap doubleTap', false);
var vConsole = new VConsole();
<div id="test">
<div class="one">
one
</div>
<div class="two">
two
</div>
</div>
<script src="//wechatfe.github.io/vconsole/lib/vconsole.min.js?v=3.0.0.0">
</script>
<script src="//cdn.bootcss.com/zepto/1.0rc1/zepto.min.js">
</script>
#test {
overflow: hidden;
margin: 50px auto;
width: 300px;
height: 300px;
border: 1px solid #ccc;
}
.one,
.two {
float: left;
margin: 10px;
width: 100px;
height: 100px;
text-align: center;
line-height: 100px;
font-size: 32px;
}
.one {
background-color: #ccc;
}
.two {
background-color: #999;
}