var
chkbox
=
document.createElement(
"
INPUT
"
);
chkbox.type = " checkbox " ;
chkbox.checked = true ;
lnk.parentNode.appendChild(chkbox);
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 ;
chkbox.type = " checkbox " ;
lnk.parentNode.appendChild(chkbox);
chkbox.checked = true ;