JSFiddle - React, Tailwind, and code Playground

by Sajid Sidhu

HTML

<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.1.1.min.js"></script>

<div id="attributs">
    <input type="radio" id="1" value="1"/>
    <input type="radio" id="2"  value="2"/>
    <input type="radio" id="3"  value="3"/>
    <input type="radio" id="4"  value="4"/>
    <input type="radio" id="5"  value="5"/>
</div>

JavaScript

$('[type="radio"]').click(function () {
            
                if ($(this).attr('checked')) {
                
                   	$(this).removeAttr('checked');
                    $(this).prop('checked',false);
                    
                } else {
                
                    $(this).attr('checked', 'checked');
                
                }
            });