JSFiddle - React, Tailwind, and code Playground
HTML
<input type='radio' class='radio-button' name='name'>
<input type='radio' class='radio-button' name='name'>
<input type='radio' class='radio-button' name='name'>
JavaScript
InitRadio('name');
function InitRadio(name){
val=0;
$.each($(':radio[name="'+name+'"]'), function(){
console.log(1);
$(this).val(val++);
$(this).attr('chk', '0');
$(this).on("click", function(event){
SetRadioButtonChkProperty($(this).val(), name);
});
});
}
function SetRadioButtonChkProperty(val, name){
$.each($(':radio[name="'+name+'"]'), function(){
if ($(this).val()!=val)
$(this).attr('chk', '0');
else {if ($(this).attr('chk') == '0')
$(this).attr('chk', '1');
else {
$(this).attr('chk', '0');
$(this).prop('checked', false);
}}
});
}