Advertisement
viligen

lockedProfile

Jun 1st, 2022
881
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function lockedProfile() {
  2.     let allRadioBtns = document.querySelectorAll("input[type = radio]");
  3.  
  4.     for (let btn of allRadioBtns) {
  5.         btn.addEventListener("click", unlockFunc);
  6.     }
  7.  
  8.     function unlockFunc(event) {
  9.         if (event.target.value == "unlock") {
  10.             console.log(event.target.value);
  11.             let parentDiv = event.target.parentElement;
  12.  
  13.             let showmoreBtn = parentDiv.children[parentDiv.children.length - 1];
  14.             showmoreBtn.disabled = false;
  15.             showmoreBtn.addEventListener("click", moreInfo);
  16.             let hiddenDiv = parentDiv.children[parentDiv.children.length - 2];
  17.             function moreInfo(ev) {
  18.                 if (ev.target.textContent == "Show more") {
  19.                     hiddenDiv.style.display = "block";
  20.                     ev.target.textContent = "Hide it";
  21.                 } else {
  22.                     hiddenDiv.style.display = "none";
  23.                     ev.target.textContent = "Show more";
  24.                 }
  25.             }
  26.         }
  27.         if (event.target.value == "lock") {
  28.             console.log(event.target.value);
  29.             let parentDiv = event.target.parentElement;
  30.             console.log(parentDiv);
  31.             let showmoreBtn = parentDiv.children[parentDiv.children.length - 1];
  32.             showmoreBtn.disabled = true;
  33.             showmoreBtn.addEventListener("click", moreInfo);
  34.             //removeEventListener("click", moreInfo);
  35.             let hiddenDiv = parentDiv.children[parentDiv.children.length - 2];
  36.             function moreInfo(ev) {
  37.                 if (ev.target.textContent == "Show more") {
  38.                     hiddenDiv.style.display = "block";
  39.                     ev.target.textContent = "Hide it";
  40.                 } else {
  41.                     hiddenDiv.style.display = "none";
  42.                     ev.target.textContent = "Show more";
  43.                 }
  44.             }
  45.         }
  46.     }
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement