You can create a listener for the radio
, but it makes no sense to check if it’s checked, because the radio
will always be checked when clicked (unlike checkbox
, which can be checked and unrecognised).
The listener would be like this:
var radio = document.querySelector('#radioButton1');
radio.addEventListener('click', function(){
alert("checado");
});
Where the id
of radio
you wish to hear is #radioButton1
.
Example:
var radio = document.querySelector('#radioButton1');
radio.addEventListener('click', function(){
alert("checado");
});
<input id="radioButton1" name="radio" type="radio" />
<input name="radio" type="radio" />