I have a basic function that alters the default text styling when a checkbox is checked, and restores it to its original state when the checkbox is unchecked.
Despite my efforts, the terms.style = "";
line does not reset the style as expected. I am perplexed by this issue and cannot figure out why. I have confirmed that the else statement executes correctly when the checkbox is unchecked, as I manually tried changing the styles.
const form = document.getElementById('form');
const checkBox = form.querySelector('input[name=termsCheckBox]');
checkBox.addEventListener('click', function(){
const terms = document.getElementById('termsText');
if (checkBox.checked){
terms.style = "color: black; font-weight: normal";
} else {
terms.style = "";
}
});//end of function