Last active
January 31, 2025 14:38
-
-
Save odessy/2737b0f323fb22bc4e60f7c5e2c828ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('DOMContentLoaded', function() { | |
const buttons = document.querySelectorAll(".btn"); | |
buttons.forEach((btn)=>{ | |
btn.addEventListener('click', (event)=>{ | |
const id = btn.getAttribute("href"); | |
const div = document.querySelector(id); | |
if(div){ | |
//hide other dives | |
const otherDivs = div.parentNode.querySelectorAll('div[id^="q_"]'); | |
otherDivs.forEach((other)=>{ | |
other.style.display = 'none' | |
}); | |
//show selected div | |
div.classList.add('fit'); | |
div.style.display = 'block'; | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment