Advertisement
GeorgiLukanov87

Locked profile

Feb 25th, 2023
716
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function lockedProfile() {
  2.     let buttonsElements = Array.from(document.querySelectorAll('.profile button'))
  3.     buttonsElements.forEach(btn => btn.addEventListener('click', onClick))
  4.  
  5.     function onClick(event) {
  6.         let currentProfile = event.target.parentElement
  7.         let isLocked = currentProfile.querySelector('input[value="unlock"]').checked;
  8.         let toShow = currentProfile.querySelector(".profile div")
  9.         if (isLocked) {
  10.  
  11.             if (event.target.textContent === 'Show more') {
  12.                 toShow.style.display = 'block'
  13.                 event.target.textContent = 'Hide'
  14.             }
  15.             else {
  16.                 toShow.style.display = 'none'
  17.                 event.target.textContent = 'Show more'
  18.             }
  19.         }
  20.  
  21.     }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement