Advertisement
mihalkoff

Sections

Feb 2nd, 2022
1,078
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function create(words) {
  2.    let content = document.getElementById('content');
  3.    for(let el of words) {
  4.       let div = document.createElement('div');
  5.       let p = document.createElement('p');
  6.       let text = document.createTextNode(el);
  7.  
  8.       p.appendChild(text);
  9.       p.style.display = 'none';
  10.       div.appendChild(p);
  11.  
  12.       div.addEventListener('click', displayElement);
  13.      
  14.       content.appendChild(div);
  15.    }
  16.  
  17.    function displayElement(e) {
  18.       e.target.children[0].style.display = 'block';
  19.    }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement