Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function lockedProfile() {
- let allRadioBtns = document.querySelectorAll("input[type = radio]");
- for (let btn of allRadioBtns) {
- btn.addEventListener("click", unlockFunc);
- }
- function unlockFunc(event) {
- if (event.target.value == "unlock") {
- console.log(event.target.value);
- let parentDiv = event.target.parentElement;
- let showmoreBtn = parentDiv.children[parentDiv.children.length - 1];
- showmoreBtn.disabled = false;
- showmoreBtn.addEventListener("click", moreInfo);
- let hiddenDiv = parentDiv.children[parentDiv.children.length - 2];
- function moreInfo(ev) {
- if (ev.target.textContent == "Show more") {
- hiddenDiv.style.display = "block";
- ev.target.textContent = "Hide it";
- } else {
- hiddenDiv.style.display = "none";
- ev.target.textContent = "Show more";
- }
- }
- }
- if (event.target.value == "lock") {
- console.log(event.target.value);
- let parentDiv = event.target.parentElement;
- console.log(parentDiv);
- let showmoreBtn = parentDiv.children[parentDiv.children.length - 1];
- showmoreBtn.disabled = true;
- showmoreBtn.addEventListener("click", moreInfo);
- //removeEventListener("click", moreInfo);
- let hiddenDiv = parentDiv.children[parentDiv.children.length - 2];
- function moreInfo(ev) {
- if (ev.target.textContent == "Show more") {
- hiddenDiv.style.display = "block";
- ev.target.textContent = "Hide it";
- } else {
- hiddenDiv.style.display = "none";
- ev.target.textContent = "Show more";
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement