<script>
var grd = function(){
$("input[type='radio']").click(function() {
var previousValue = $(this).attr('previousValue');
var name = $(this).attr('name');
if (previousValue == 'checked') {
$(this).removeAttr('checked');
$(this).attr('previousValue', false);
} else {
$("input[name="+name+"]:radio").attr('previousValue', false);
$(this).attr('previousValue', 'checked');
}
});
};
grd('1');
</script>
<input type="radio" name="1" class="radio">
<input type="radio" name="1" class="radio">
<input type="radio" name="1" class="radio">
<input type="radio" name="1" class="radio">
<br>
<input type="radio" name="2" class="radio">
<input type="radio" name="2" class="radio">
<input type="radio" name="2" class="radio">
<input type="radio" name="2" class="radio">
var grd = function(){
$("input[type='radio']").click(function() {
var previousValue = $(this).attr('previousValue');
var name = $(this).attr('name');
if (previousValue == 'checked') {
$(this).removeAttr('checked');
$(this).attr('previousValue', false);
} else {
$("input[name="+name+"]:radio").attr('previousValue', false);
$(this).attr('previousValue', 'checked');
}
});
};
grd('1');
</script>
<input type="radio" name="1" class="radio">
<input type="radio" name="1" class="radio">
<input type="radio" name="1" class="radio">
<input type="radio" name="1" class="radio">
<br>
<input type="radio" name="2" class="radio">
<input type="radio" name="2" class="radio">
<input type="radio" name="2" class="radio">
<input type="radio" name="2" class="radio">