100-project-100-days-website/100_projects/50-‏line-through-effect/main.js
2023-04-12 01:41:29 +03:00
Ask

13 lines
447 B
JavaScript

{8beb218b25356ec9b0a035ebde745ee0ee630601 true 447 main.js 0xc001db31f0}

const text = document.getElementById('text');
const textArr = text.innerText.split('');
const newEl = document.createElement('h1');
newEl.innerHTML = `${textArr.map(letter => `<span class="letter" style="${randomVisibility()}">${letter}</span>`).join('')}`;
newEl.classList.add('overlay');
document.body.appendChild(newEl);
function randomVisibility() {
return Math.random() < 0.5 ? 'visibility: hidden' : 'visibility: visible';
}