Advertisement
kstoyanov

01. Sections

Oct 1st, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function create(words) {
  2.   const mainDiv = document.getElementById('content');
  3.   words.forEach((word) => {
  4.     const divElement = document.createElement('div');
  5.     const pElement = document.createElement('p');
  6.     pElement.style.display = 'none';
  7.     pElement.textContent = word;
  8.     divElement.appendChild(pElement);
  9.  
  10.     divElement.addEventListener('click', (e) => {
  11.       const targetPElement = e.target.firstChild;
  12.       targetPElement.style.display = 'block';
  13.     });
  14.     mainDiv.appendChild(divElement);
  15.   });
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement