JSFiddle - React, Tailwind, and code Playground
HTML
<button id="button">start</button>
<div id="timer"></div>
JavaScript
const btn = document.getElementById('button');
const timer = document.getElementById('timer');
let si; // Тут будет хранится таймер
function startTimer() {
if (si) {
alert('Таймер уже запущен')
} else {
let sec = 10;
si = setInterval(() => {
timer.innerText = sec--;
if (sec < 0) {
si = clearInterval(si);
let el = document.createElement('p');
el.innerText = 'Нужный блок';
document.body.append(el);
}
}, 1000);
}
}
btn.onclick = () => {
startTimer();
}