复制代码 代码如下:
复制代码
var chkbox = document.createElement("INPUT");
chkbox.type = "checkbox";
chkbox.checked=true;
lnk.parentNode.appendChild(chkbox);
var chkbox = document.createElement("INPUT");
chkbox.type = "checkbox";
chkbox.checked=true;
lnk.parentNode.appendChild(chkbox);
以上代码在IE7下,生成的Checkbox无法正确的打上勾。
原因是 chkbox控件还没初始化(appendChild),就开始操作它的结果
据此将代码改为即可正确显示:
复制代码 代码如下:
复制代码
var chkbox = document.createElement("INPUT");
chkbox.type = "checkbox";
lnk.parentNode.appendChild(chkbox);
chkbox.checked=true;
var chkbox = document.createElement("INPUT");
chkbox.type = "checkbox";
lnk.parentNode.appendChild(chkbox);
chkbox.checked=true;
最后
以上就是专一小虾米最近收集整理的关于IE7中javascript操作CheckBox的checked=true不打勾的解决方法的全部内容,更多相关IE7中javascript操作CheckBox内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复