Add a throttle that only allows the click to happen after 2 seconds of mousedown.
var timer;
$('div').on("mousedown",function(){
timer = setTimeout(function(){
alert("WORKY");
},2*1000);
}).on("mouseup mouseleave",function(){
clearTimeout(timer);
});
Edit: I added mouseleave too since if the mouse leaves the element and then triggers mouseup, it won't stop the timer.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…