六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 113|回复: 0

IE对select的处理,又一怪现象:innerHTML竟然不起作用。

[复制链接]

升级  50%

37

主题

37

主题

37

主题

秀才

Rank: 2

积分
125
 楼主| 发表于 2013-2-7 21:20:18 | 显示全部楼层 |阅读模式
我们用select来选取一个国家,当我辛辛苦苦拼凑字符串,然后把这个字符串赋值给select的innerHTML,运行,在firefox下能显示出所有的国家。但是在IE下却什么都没有显示。刚开始我还以为是我拼凑的字符串有问题,仔细检查没有啊。后台到google上search了下,发现是ie处理select的一个bug。于是做了一个简单的测试。
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee;"> 1<html>
 2<head>
 3<title>test</title>
 4<script language="javascript">
 5function test(){
 6    var elem=document.getElementById("testS");    
 7    elem.innerHTML="<option value=1>aa</option>";
 8}
 9
10</script>
11</head>
12<body>
13<input type=button value=test onclick='test()'>
14<div>
15    <select id='testS'></select>
16</div>
17</body>
18</html>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表