You can create a listener for radio
, but it does not make sense to check that it is checked, since radio
will always be checked when clicked (as opposed to checkbox
, which can be checked and unrecognized) .
The listener would look like this:
var radio = document.querySelector('#radioButton1');
radio.addEventListener('click', function(){
alert("checado");
});
Where id
of radio
you want 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" />