我们用select来选取一个国家,当我辛辛苦苦拼凑字符串,然后把这个字符串赋值给select的innerHTML,运行,在firefox下能显示出所有的国家。但是在IE下却什么都没有显示。刚开始我还以为是我拼凑的字符串有问题,仔细检查没有啊。后台到google上search了下,发现是ie处理select的一个bug。于是做了一个简单的测试。
1
<
html
>
2
<
head
>
3
<
title
>
test
</
title
>
4
<
script
language
="javascript"
>
5
function 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
>

2

3

4



5



6

7

8

9

10

11

12

13

14

15

16

17

18

点击test按钮,在IE下,select框没有任何的内容。怪异啊!
于是不得不利用Option对象来增加select的内容。