Kev*_*_TA 2 html javascript jquery
我注意到Mozilla的刷新并没有使页面空白.我在表单上有复选框,我需要在页面加载/刷新时取消选中.目前我正在使用这个:
<body onLoad="uncheck()">
function uncheck() {
// Uncheck all checkboxes on page load
$("input:checkbox:checked").attr("checked", "");
console.log("uncheck");
}
Run Code Online (Sandbox Code Playgroud)
这适用于完全加载页面,但如果我单击刷新(在Mozilla中),则正确调用该函数,因为"取消选中"正在打印到控制台,但复选框仍在检查中.
有什么想法吗?
Eng*_*eer 14
请改用prop:
$(':checkbox:checked').prop('checked',false);
Run Code Online (Sandbox Code Playgroud)
或者removeAttr:
$(':checkbox:checked').removeAttr('checked');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9746 次 |
| 最近记录: |