var timeoutId = 0;$('#myElement').on('mousedown', function() { timeoutId = setTimeout(myFunction, 1000);}).on('mouseup mouseleave', function() { clearTimeout(timeoutId);});编辑 :每个AndyE的更正…谢谢!
编辑2 :现在为每个gnarf对具有相同处理程序的两个事件使用bind

var timeoutId = 0;$('#myElement').on('mousedown', function() { timeoutId = setTimeout(myFunction, 1000);}).on('mouseup mouseleave', function() { clearTimeout(timeoutId);});编辑 :每个AndyE的更正…谢谢!
编辑2 :现在为每个gnarf对具有相同处理程序的两个事件使用bind