window.onload = function () {
startTimer(5, document.getElementById("time")); // 5 - сколько секунд ; document.getElementById("time") - блок, где нужно значение
startTimer(10, document.getElementById("time1"));
};
function startTimer(duration, display) {
var start = Date.now(),
diff,
minutes,
seconds;
function timer() {
diff = duration - (((Date.now() - start) / 1000) | 0);
minutes = (diff / 60) | 0;
seconds = (diff % 60) | 0;
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
if ( minutes === '00' && seconds === '00') {
display.textContent = 'текст'; // тут ваш текст
clearInterval(interval)
} else {
display.textContent = minutes + ":" + seconds;
}
if (diff <= 0) {
start = Date.now() + 1000;
}
};
var interval = setInterval(timer, 1000);
timer();
}