I am trying to toggle a couple of radio buttons using jQuery. But it is turning out to be not so simple.
<button id="toggler">click me</button><br>
<input type="radio" name="speeds" value="fast" checked>fast<br>
<input type="radio" name="speeds" value="slow">slow<br>
$('#toggler').click(function() {
$('input[name="speeds"]').each(function(){
$(this).prop("checked", !$(this).prop("checked"));
});
});
Could anyone please explain why the code above does not work?
See Question&Answers more detail:os