我在一个子页面中使用了一个asp.net网格视图控件。网格有两个相邻的复选框列,第二列中的框在启动时被禁用。当用户选中第一列中一行中的复选框时,相邻的复选框将变为启用状态。我的以下代码在Chrome和FoxFire中运行良好,但在IE 10或11中运行不佳。为了检查语法,我添加了一个替代响应,通过该响应,相邻的复选框将变为单击而不是启用。这在IE中是有效的。因此,IE似乎能够识别和更改"Checked“属性,但不能识别和更改"Disabled”属性。我试着用"attr“代替”prop“,但得到了同样的结果。当我用"click“事件替换"change”事件时,也会得到同样的结果。IE浏览器有解决方法吗?谢谢你的帮助。
Ken McLean
<script type="text/javascript">
$(document).ready(function() {
var chx = $('input[type="checkbox"]');
chx.change(function() {
var i = chx.index(this);
if (this.id.endsWith("chkCourse")) {
if ($(this).is(":checked")) {
//$(chx[i + 1]).prop("checked", true); this works in IE
$(chx[i + 1]).prop( "disabled", false ); // this does not
}
else {
//$(chx[i + 1]).prop("checked", false); this works in IE
$(chx[i + 1]).prop( "disabled", true ); // this does not
};
};
});
});
</script>发布于 2015-06-24 03:55:01
我在StackOverFlow的其他地方找到了我的问题的解决方案。我使用的是ASP.Net复选框。以下是解决方案:
将呈现为具有和标记的。当复选框处于禁用状态时,span和input标记都将使用disabled属性进行修饰。为了获得预期的行为,我使用了以下代码:
$(‘myCheckBox’)禁用(‘.removeAttr’);$('myCheckBox').closest('span').removeAttr('disabled');
https://stackoverflow.com/questions/30993637
复制相似问题