setInterval挂起。之后setInterval不会清除。
var timer = 0;
document.getElementById('c_3').onmousedown = function(e) {
timer = setInterval(function() {myFunction();}, 30);
if (e.which == 2 || e.which == 3) {
clearInterval(timer);
}
}
答案 0 :(得分:0)
这就是它现在的运作方式......
let timer = 0;
document.getElementById('c_3').onmousedown = function(e) {
if (e.which == 1) {
timer = setInterval(function() {myFunction();}, 30);
}
if (e.which == 2 || e.which == 3) {
document.getElementById('c_3').oncontextmenu = function() {
return false;
}
clearInterval(timer);
}
}
document.getElementById('c_3').onmouseup = function() {
clearInterval(timer);
}