Select Page

Código jQuery que permite hacer deseleccionable un conjunto de radio botones

<input type="radio" value="1" name="optionId" id="rb1"/><label for="rb1">Radio 1</label>
<input type="radio" value="2" name="optionId" id="rb2"/><label for="rb2">Radio 2</label>
<input type="radio" value="3" name="optionId" id="rb3"/><label for="rb3">Radio 3</label>
$(document).ready(function(){
$("input:radio[name='optionId']:checked").data("chk",true);
$("input:radio[name='optionId']").click(function(){
$("input[name='"+$(this).attr("name")+"']:radio").not(this).removeData("chk");
$(this).data("chk",!$(this).data("chk"));
$(this).prop("checked",$(this).data("chk"));
});
});