今天在使用jquery動態設置layui的checkbox元素的選中狀態時始終只能取消選中,卻不能重新勾選,點擊勾選則沒有問題,代碼如下
if (value == "true") {
$("#select1").attr("checked", "checked");
} else {
$("#select1").removeAttr("checked");
}
百度很久終於找到一個可用的解決方案,使用prop代替attr,如下:
if (value == "true") {
//$id.attr("checked", "checked");
$id.prop("checked", true);
} else {
$id.prop("checked", false);
//$id.removeAttr("checked");
}
博客遷移到github了,這邊基本不更新,
主要是沒有找到快捷的同步方法,手動同步太麻煩了,如果你有快速把github博客同步到博客園的方法請一定告訴我
別忘了告訴我!!!
別忘了告訴我!!!
別忘了告訴我!!!