Today, I saw a large screen of video in which the words of the paragraph are displayed one by one. So there’s this note
function showText(showElDom,str='',speed=100){ if(! ShowElDom){console.error(' This element does not exist '); return; } let strArr = str.trim().split(""); let newStr = ''; let len = strArr.length; let number = 0; let timer = setInterval(() => { if (number > len-1) { clearInterval(timer); return; } newStr += strArr[number]; showElDom.innerText = newStr; number++; }, 100); } showText(document.querySelector("p"),' This element does not exist this element does not exist ');Copy the code