Advertisement
Threed90

Selections

Jan 27th, 2022
861
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function create(words) {
  2.    let divs = [];
  3.    let divElement = document.getElementById('content');
  4.    for (const word of words) {
  5.       let div = document.createElement('div');
  6.       let p = document.createElement('p');
  7.       p.textContent = word;
  8.       p.setAttribute('style', 'display:none;');
  9.       div.appendChild(p)
  10.       divElement.appendChild(div);
  11.    }
  12.  
  13.    divElement.addEventListener('click', (e) => {
  14.       if (e.target.tagName === 'DIV' && !e.target.getAttribute('id')) {
  15.          let el = e.target.querySelector('p');
  16.          el.style.display = 'block';
  17.       }
  18.    });
  19. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement