取消选中Mozilla Refresh上的复选框 [英] Uncheck Checkboxes on Mozilla Refresh
本文介绍了取消选中Mozilla Refresh上的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我注意到Mozilla的刷新并没有使页面变成空白。当页面加载/刷新时,我需要取消选中表单上的复选框。目前我使用的是:
I've noticed that Mozilla's refresh doesn't bring the page to a blank slate. I have checkboxes on the form that I need to be unchecked when the page is loaded/refreshed. Currently I am using this:
<body onLoad="uncheck()">
function uncheck() {
// Uncheck all checkboxes on page load
$("input:checkbox:checked").attr("checked", "");
console.log("uncheck");
}
这适用于完全加载页面,但如果我单击刷新(在Mozilla )函数被正确调用,因为uncheck正在打印到控制台,但复选框仍然被检查。
This works for loading the page completely, but if i click refresh (in Mozilla) the function is called properly because "uncheck" is being printed to the console, but the checkboxes are remaining checked.
有什么想法?
推荐答案
Use prop instead:
$(':checkbox:checked').prop('checked',false);
或 removeAttr :
$(':checkbox:checked').removeAttr('checked');
这篇关于取消选中Mozilla Refresh上的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文