poll assignment.

This commit is contained in:
Joshua Ashton
2025-02-08 14:02:54 -07:00
parent 83fa29d54c
commit 2a98edbc6f
12 changed files with 276 additions and 51 deletions
View File
+17
View File
@@ -0,0 +1,17 @@
const radioButtons = document.querySelectorAll('input[type="radio"]');
radioButtons.forEach(radio => {
radio.addEventListener('change', () => {
// Remove 'checked' class from all labels
radioButtons.forEach(otherRadio => {
otherRadio.parentNode.classList.remove('checked'); // parentNode gets the label
console.log('removed checked');
});
// Add 'checked' class to the currently selected label
if (radio.checked) {
radio.parentNode.classList.add('checked');
console.log('added checked');
}
});
});