在IE中,在使用checkbox或radio时,你会发现有时不能通过CheckBoxObject.checked = true或CheckBoxObject.setAttribute('checked', true)的方法使checkbox或radio被预选中。
解决这个问题的方法就是利用checkbox或radio的defaultChecked的属性,将defaultChecked属性置为true即可,具体实现是 CheckBoxObject.setAttribute('defaultChecked', true)或 CheckBoxObject.defaultChecked= true,这样就能实现checkbox和radio在IE中初始状态下被选中了。
具体例子:
实现代码如下:

<script type="text/javascript"><!--
var test1= document.getElementById("checkboxID");
test1.setAttribute('defaultChecked',true);
// --></script>

以上就是【IE中radio 或checkbox的checked属性初始状态下不能选中显示问题】的全部内容了,欢迎留言评论进行交流!

赞(0) 踩(0)

与本文相关的软件

发表我的评论

最新评论

  1. 暂无评论