我试图在mousedown-up事件上的一个按钮上做两个不同的功能.但它没有工作,因为我无法检测到mousedown事件的时间.
var flag;
$("#ClikerButton").mousedown(function(e){
//if mouse pressed more than 2 sec, then
// do func1 and set flag = true;
//else do nothing
}).mouseup(function(e){
//if flag == true, do nothing,
//else do func2;
});
Run Code Online (Sandbox Code Playgroud)