I have radio buttons and one of them :checked
and they have the same name. When I click another radio button they are both selected.
My code is:
<input name="a" type="radio">
<input name="a "type="radio" checked>
JS
$("input[type='radio']").each(function () {
if ($(this).is(":checked")) {
$(this).addClass("some");
}
});
CSS
.some {
background-color:#06c!important;
}
My approach is to first check if my inputs are :checked
and if they are, put some css class with background color. I achieve that, the next thing I want to is remove that :checked
when users click on radio button or any other (better) idea. Right now both radio buttons are selected. Can anybody help me with this?
Fiddle:
https://jsfiddle.net/0ns58xcq/