一个简单的例子,是懒宝宝让我帮忙的。因为我自己也注意到了,radio在选中后,一般无法取消,查了一下google,发现还是有方法 的。因此,立马解决了:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<table class="rs" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>HIV :阴
<input type="radio" name="hiv[0]" value="HIV:阴" union="yin"/>
阳
<input type="radio" name="hiv[0]" value="HIV:阳" union="yang" /></td>
<td>梅毒:阴
<input type="radio" name="hiv[1]" value="梅毒:阴" union="yin" />
阳
<input type="radio" name="hiv[1]" value="梅毒:阳" union="yang" /></td>
<td>疱疹:阴
<input type="radio" name="hiv[2]" value="疱疹:阴" union="yin" />
阳
<input type="radio" name="hiv[2]" value="疱疹:阳" union="yang" /></td>
<td>淋病:阴
<input type="radio" name="hiv[3]" value="淋病:阴" union="yin" />
阳
<input type="radio" name="hiv[3]" value="淋病:阳" union="yang" /></td>
</tr>
<tr>
<td>非淋:阴
<input type="radio" name="hiv[4]" value="非淋:阴" union="yin" />
阳
<input type="radio" name="hiv[4]" value="非淋:阳" union="yang" /></td>
<td>湿疣:阴
<input type="radio" name="hiv[5]" value="湿疣:阴" union="yin" />
阳
<input type="radio" name="hiv[5]" value="湿疣:阳" union="yang" /></td>
<td>丙肝:阴
<input type="radio" name="hiv[6]" value="丙肝:阴" union="yin" />
阳
<input type="radio" name="hiv[6]" value="丙肝:阳" union="yang" /></td>
<td><a style="cursor:pointer;" id='allyin'>全阴</a> <a style="cursor:pointer;" id='allyang'>全阳</a> <a id='allempty' style="cursor:pointer;">重填</a>
<script>
$(function(){
$('#allyin').click(function(){
$(':input[union="yin"]').attr('checked','checked');
});
$('#allyang').click(function(){
$(':input[union=yang]').attr('checked','checked');
});
$('#allempty').click(function(){
$(':input[union=yang]').each(function(){
$(this).attr('checked','checked');
var tmp = $(this)[0];
tmp.checked = false;
tmp = null;
})
});
});
</script></td>
</tr>
</table>
因为用jquery的话,选中radion的方法很方便。所以,就尝试用这种方式解决了。。。但是用jquery无法取消checked状态,只能用原生js的方式才行(jquery是把元素都转换为对象,而不是DOM对象)

评论 (0)
暂无评论