I want to pause/stop a running function below when the other function is firing.
function log(msg) {document.getElementById('log').innerHTML = msg + '<br/>';}
var a = function() {
var j = 0;
setInterval(function() {
log('A: ' + j++);
},1000);
}
var b = function() {
var j = 1001;
setInterval(function() {
log('B: ' + j++);
},1000);
}
var b1 = document.getElementById('button1')
, b2 = document.getElementById('button2');
b1.addEventListener('click', a, false);
b2.addEventListener('click', b, false);
Also, I want to prevent these functions from double fired (or fired multiple times) if I hit a button repeatedly.
Thank you,