IE7中javascript操作CheckBox的checked=true不打勾的解决方法
作者:bea
代码如下: var chkbox = document.createElement("INPUT"); chkbox.type = "checkbox"; chkbox.checked=true; lnk.parentNode.appendChild(chkbox); 以上代码在IE7下,生成的Checkbox无法正确的打上勾。 原因是 chkbox控件还没初始化(appendChild),就开始操作它的结果 据此将代码改为即可正确显示: 代码如下: v
代码如下:
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;
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- 可以用来搜索当前页面内容的js代码
- javascript弹出窗口 window.open使用方法以及参数说明分析篇
- javascript setTimeout和setInterval 的区别
- javascript OFFICE控件测试代码
- JavaScript Cookie 直接浏览网站分网址
- JavaScript Cookie显示用户上次访问的时间和次数
- JavaScript 利用Cookie记录用户登录信息
- JavaScript Cookie的读取和写入函数
- jquery 双色表格实现代码
- javascript检测(控制 )上传文件大小
- IE浏览器打印的页眉页脚设置解决方法
- jQuery Selectors(选择器)的使用(六、属性篇)
- JQuery 表单中textarea字数限制实现代码
- 测试JavaScript字符串处理性能的代码
- javascript 混合的构造函数和原型方式,动态原型方式
- JavaScript 常见对象类创建代码与优缺点分析
- javascript prototype原型操作笔记
- javascript 面向对象的经典实例代码
- javascript Array.sort() 跨浏览器下需要考虑的问题