如何让checkbox复选框只能单选
如何让checkbox复选框只能单选
在项目开发中遇到一个这样的问题,要让一列复选框架在任何时间段内只能选择一个。
有人说怎么不用单选框了,因为单选框一旦选择了就不能取消选择,所以这里只能用复选框。
经过思考发现可以能过js控制复选框只能单选,实现方法如下:
$("#txm").find(".checkbox").each(function(){
$(this).click(function(){
var test= $(this).attr("checked");
if(this.checked){
GetData(this.value);
$(this).parent("div").siblings().children(".checkbox").each(function(){
if(test== this.checked){
this.checked = false;
}
});
}
});
});
});
浙公网安备 33010602011771号