ie中js创建checkbox默认选中问题探讨


测试浏览器:ie8(兼容和不兼容模式),ff6。
复制代码 代码如下:

var chk = document.createElement("input");
chk.setAttribute("type","checkbox");
container.appendChild(chk);
chk.setAttribute("checked",true);

以上代码在ie8兼容模式和ff6下都没有总是,但在ie8不兼容模式下不起作用,只有在appendChild后,再设置checked的值就都起作用,如下:
复制代码 代码如下:

var chk = document.createElement("input");
chk.setAttribute("type","checkbox");
chk.setAttribute("checked",true);
container.appendChild(chk);

貌似以上这段话反了。
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3