Setting innerHtml of a selection box in IE

匿名 (未验证) 提交于 2019-12-03 01:58:03

问题:

On my website there is a situation where I need to append new tags to a specific selection box. I am doing the following:

1.Make an ajax request which returns option tags like

 

etc.,

2.Set the inner html of a specific selection box by

 document.getElementById("id").innerHTML=response; 

it works well in firefox/chrome but not in IE....

any known solution for this..??

回答1:

It's a known IE bug. You can either user DOM methods to append/replace the option elements, or you can use the workarounds suggested by Microsoft, one of which is to wrap your select in a div and set the div's innerHTML to "



回答2:

http://support.microsoft.com/kb/276228

It's a known issue in IE. Sorry for wasting everyone's time, long story short options.innerHTML is buggy. The work around Microsoft suggest is wrapping your tag in a tag. Then you can use the div.innerHTML to change the code.

 
var x ='\n'; IEFix.innerHTML = x;


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!