IE7中javascript操作CheckBox的checked=true不打勾解决方法

 

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;

 

 

posted @ 2009-12-05 23:37  coudly  阅读(873)  评论(0编辑  收藏  举报