用js捕捉鼠标连续点击三次事件怎么实现啊

var count = 0, timer;
document.onclick = function(){
if(count < 2){
if(timer){
clearTimeout(timer);
}
count ++;
timer = setTimeout(function(){
count = 0;
}, 500);
}else if(count === 2){
count = 0;
clearTimeout(timer);
threeClick();
}
}
function threeClick(){
alert('three click');
}

posted @ 2015-02-05 17:59  经验源于积累  阅读(694)  评论(0编辑  收藏  举报