我想在mousedown - up事件上的一个按钮上做2个不同的功能。 但它不工作,因为我无法检测到mousedown事件的时间。如何计算jouery中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;
});
感谢您的快速回复。现在工作正常。我不知道mousedown事件有downTimer变量。如果有更多downTimer变量的详细信息以及upTimer变量(如果可用),请提供给我。还提供了使用behing downTimer变量的编码... –