<input type="checkbox" id="all" ><span>全店商品</span>
<input type="checkbox" id="zhiding" checked="true"><span>指定商品范围</span>
$('#all').click(function () {
if ($(this).is(":checked")) {
$('#zhiding').attr("checked" , false)
$("#jichu").find("input").val("").focus(); //清空text中的值
$("#jichu").find("input").attr("readonly" , "readonly"); //让文本框只读
}})
$('#zhiding').click(function () {
if ($(this).is(":checked")){
$('#all').attr("checked" , false)
$("#jichu").find("input").removeAttr("readonly" , "readonly");
$('#zhiding').removeAttr("disabled","disabled");
$('#zhiding').attr("checked","checked");
}
})
checked="true" 和
checked="chengked"
效果一样,都是选中状态
js实现按钮选中与不选中