IE下 JS添加Select元素的option问题

 IE6对Select元素的支持有bug,使用中发现js使用dom标准方式添加option有问题, FF下显示正常, IE下元素添加进去了,但文本不显示。

错误的方式如下:

      var ItemOption = document.createElement("OPTION");
                var sel = document.getElementById("ArticleTypeId");               
                ItemOption.text = "aaa1";
                ItemOption.value = "asd";
                 sel.appendChild(ItemOption);

解决方法如下 :

      var ItemOption = document.createElement("OPTION");
                var sel = document.getElementById("select1");
                sel.appendChild(ItemOption);
                ItemOption.text = "aaa1";
                ItemOption.value = "asd";  

看出来区别了么,就在于先添加元素还是后添加元素的区别。!!!!汗!

posted @ 2011-06-07 11:51  Grok.Yao  阅读(1208)  评论(1编辑  收藏  举报