Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
1,651
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function lockedProfile() {
  2.     const btns = [...document.getElementsByTagName('button')];
  3.     btns.forEach(btn => btn.addEventListener('click', showHide));
  4.  
  5.     function showHide(event) {
  6.         const button = event.target;
  7.         const profile = button.parentNode;
  8.         const moreInformation = profile.getElementsByTagName('div')[0];
  9.         const lockStatus = profile.querySelector('input[type="radio"]:checked').value;
  10.  
  11.         if (lockStatus === 'unlock') {
  12.             if (button.textContent === 'Show more') {
  13.                 moreInformation.style.display = 'inline-block';
  14.                 button.textContent = 'Hide it';
  15.             } else if (button.textContent === 'Hide it') {
  16.                 moreInformation.style.display = 'none';
  17.                 button.textContent = 'Show more';
  18.             }
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement