Jquery 如何使复选框启用在ie9中工作?
以下代码在FF中不起作用。我正在尝试使用启用按钮将复选框设置为启用。启用复选框在IE 9中不起作用Jquery 如何使复选框启用在ie9中工作?,jquery,asp.net,Jquery,Asp.net,以下代码在FF中不起作用。我正在尝试使用启用按钮将复选框设置为启用。启用复选框在IE 9中不起作用 function enablebut() { $('#CheckBoxList1_0').removeAttr("disabled"); $('#CheckBoxList1 span').removeAttr("disabled"); } function disablebut() {
function enablebut() {
$('#CheckBoxList1_0').removeAttr("disabled");
$('#CheckBoxList1 span').removeAttr("disabled");
}
function disablebut() {
$('#CheckBoxList1_0').attr("disabled", true);
$('#CheckBoxList1 span').attr("disabled", true);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<button type="button" onclick="enablebut();">
enable</button>
<button type="button" onclick="disablebut();">
disable</button>
<div>
<asp:CheckBoxList ID="CheckBoxList1" Enabled='false' runat="server">
<asp:ListItem Text="een"></asp:ListItem>
</asp:CheckBoxList>
</div>
</form>
</body>
</html>
function enablebut() {
$('#CheckBoxList1_0').removeAttr("disabled");
$('#CheckBoxList1 span').removeAttr("disabled");
}
function disablebut() {
$('#CheckBoxList1_0').attr("disabled", true);
$('#CheckBoxList1 span').attr("disabled", true);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<button type="button" onclick="enablebut();">
enable</button>
<button type="button" onclick="disablebut();">
disable</button>
<div>
<asp:CheckBoxList ID="CheckBoxList1" Enabled='false' runat="server">
<asp:ListItem Text="een"></asp:ListItem>
</asp:CheckBoxList>
</div>
</form>
</body>
</html>
function enablebut(){
$('#CheckBoxList1_0').removeAttr(“禁用”);
$('#CheckBoxList1 span').removeAttr(“禁用”);
}
函数disablebut(){
$('#CheckBoxList1_0').attr(“disabled”,true);
$('#CheckBoxList1 span').attr(“disabled”,true);
}
使可能
使残废
我发现您正在使用不同的Id来选择复选框。有什么具体原因吗?
复选框的Id为“CheckBoxList1”,但您正在尝试选择Id为“CheckBoxList1_0”的复选框。我看到您使用了不同的Id来选择复选框。有什么具体原因吗?
function enablebut() {
$('#CheckBoxList1_0').removeAttr("disabled");
$('#CheckBoxList1 span').removeAttr("disabled");
}
function disablebut() {
$('#CheckBoxList1_0').attr("disabled", true);
$('#CheckBoxList1 span').attr("disabled", true);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<button type="button" onclick="enablebut();">
enable</button>
<button type="button" onclick="disablebut();">
disable</button>
<div>
<asp:CheckBoxList ID="CheckBoxList1" Enabled='false' runat="server">
<asp:ListItem Text="een"></asp:ListItem>
</asp:CheckBoxList>
</div>
</form>
</body>
</html>
复选框的Id为“CheckBoxList1”,但您正在尝试选择Id为“CheckBoxList1\u 0”的复选框。您能否使用相同的代码
function enablebut() {
$('#CheckBoxList1_0').removeAttr("disabled");
$('#CheckBoxList1 span').removeAttr("disabled");
}
function disablebut() {
$('#CheckBoxList1_0').attr("disabled", true);
$('#CheckBoxList1 span').attr("disabled", true);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<button type="button" onclick="enablebut();">
enable</button>
<button type="button" onclick="disablebut();">
disable</button>
<div>
<asp:CheckBoxList ID="CheckBoxList1" Enabled='false' runat="server">
<asp:ListItem Text="een"></asp:ListItem>
</asp:CheckBoxList>
</div>
</form>
</body>
</html>
function enablebut() {
$('#CheckBoxList1_0').attr("disabled", false);
$('#CheckBoxList1 span').attr("disabled", false);
}
只需将参数更改为
false
您不能使用相同的代码吗
function enablebut() {
$('#CheckBoxList1_0').removeAttr("disabled");
$('#CheckBoxList1 span').removeAttr("disabled");
}
function disablebut() {
$('#CheckBoxList1_0').attr("disabled", true);
$('#CheckBoxList1 span').attr("disabled", true);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<button type="button" onclick="enablebut();">
enable</button>
<button type="button" onclick="disablebut();">
disable</button>
<div>
<asp:CheckBoxList ID="CheckBoxList1" Enabled='false' runat="server">
<asp:ListItem Text="een"></asp:ListItem>
</asp:CheckBoxList>
</div>
</form>
</body>
</html>
function enablebut() {
$('#CheckBoxList1_0').attr("disabled", false);
$('#CheckBoxList1 span').attr("disabled", false);
}
只需将参数更改为
false
我认为使用JQuery,您可以像设置true时一样将attr设置为false您使用的是哪个版本的JQuery?如果是jQuery 1.6或更新版本,您应该在这里使用prop
,而不是attr
。我认为使用jQuery,您可以将attr设置为false,就像设置true时一样。您使用的是什么版本的jQuery?如果是jQuery 1.6或更高版本,您应该在此处使用prop
,而不是attr
。
function enablebut() {
$('#CheckBoxList1_0').removeAttr("disabled");
$('#CheckBoxList1 span').removeAttr("disabled");
}
function disablebut() {
$('#CheckBoxList1_0').attr("disabled", true);
$('#CheckBoxList1 span').attr("disabled", true);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<button type="button" onclick="enablebut();">
enable</button>
<button type="button" onclick="disablebut();">
disable</button>
<div>
<asp:CheckBoxList ID="CheckBoxList1" Enabled='false' runat="server">
<asp:ListItem Text="een"></asp:ListItem>
</asp:CheckBoxList>
</div>
</form>
</body>
</html>