I'm trying to use a code to get the value of the selected radio button and I'm encountering the following errors:
The 'checked' property does not exist in type 'HTMLElement'.
The 'value' property does not exist in the NodeListOf type.
Follow my code:
getRadioValor(name){
var rads = document.getElementsByName(name);
for(var i = 0; i< rads.length; i++){
if(rads[i].checked){
return rads.value;
}
}
}
What is the reason for these errors? And how to solve?