const tekst = document.getElementById("stiligtekst"); const tekstStr = tekst.textContent; const splitta = tekstStr.split(""); tekst.textContent =""; for (let i =0; i < splitta.length; i++) { tekst.innerHTML +="" + splitta[i] + ""; } let char = 0; let timer = setInterval(onTick, 100); function onTick(){ const span = tekst.querySelectorAll('span')[char]; span.classList.add('stilig'); char++; if(char === splitta.length) { complete(); return; } function complete(){ clearInterval(timer); timer = null; } }