I am using an HTML span tag to display some text if a certain radio option is chosen. If I click on the 2nd radio option, the span tag text should be overridden and turned into an empty string. The text currently does not disappear.
I have tried the style.display = "none" and I have also tried overriding the innerHTML with an empty string.
Javascript
if(timeCard[1].value == "N/A"){
document.getElementById("radioError").innerHTML = "Please verify this field before submitting.";
console.log('Hi');
}else{
document.getElementById("radioError").innerHTML = "";
}
}
HTML
<input type="radio" name="timecard" value="Yes">Yes<br>
<input type="radio" name="timecard" value="N/A">N/A<br>
<span id="radioError" style="font-size: 0.9em; color:red;"></span>
I want the span text to be overridden by the 2nd innerHTML in the javascript.