var firstInterval; var secondInterval; function firstFunction(){ if(firstInterval) clearInterval(firstInterval); //code... firstInterval = setInterval('firstFunction()', 1000); } function secondFunction(){ if(secondInterval) clearInterval(secondInterval); secondInterval = setInterval('secondFunction()', 2000);
}