我正在尝试选中一个复选框,但在IE11中不起作用。在Chrome浏览器中工作正常。有人可以向我解释为什么此代码无法在这些浏览器上运行吗?
// 01_certify_01
$(function() {
$("#calCarStartBtn").click(function() {
window.location.href = './src/views/01_certify_01.php?mode=calc';
});
$("#histCalCarBtn").click(function() {
window.location.href = './src/views/01_certify_01.php?mode=hist';
});
var textObj = $(".textarea");
var warningObj = $(".warning-box");
textObj.hide();
warningObj.hide();
$("#checkboxAgreeAll").click(function() {
var chk = $(this).prop("checked");
if (chk) {
$("input[type='checkbox']").prop("checked", true);
$("#certify01 label").css("background-image", "url('./../img/check_on.png'");
warningObj.hide();
} else {
$("input[type='checkbox']").prop("checked", false);
$("#certify01 label").css("background-image", "url('./../img/check_off.png'");
}
});
$("#checkbox1").click(function() {
checked = $(this).prop("checked");
var l = $("label[for='checkbox1']");
l.css("background-image", "url('./../img/check_on.png'");
warningObj.hide();
if (!checked) {
$("#checkboxAgreeAll").prop("checked", checked);
$("label[for='checkboxAgreeAll']").css("background-image", "url('./../img/check_off.png'");
l.css("background-image", "url('./../img/check_off.png'");
}
});
我检查了@ T.J。人群答案(here)及其在IE 11中的工作
尝试此操作以选中和取消选中复选框。
if(!($("input")[0].checked == true))
{
$("input")[0].setAttribute("checked", "checked");
}
else
{
$("input")[0].removeAttribute("checked", "checked");
}