Setting innerHtml of a selection box in IE

后端 未结 2 585
执笔经年
执笔经年 2020-12-11 23:58

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

1.Make an ajax request which

相关标签:
2条回答
  • 2020-12-12 00:22

    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.

     <div id ="IEFix">
     <select name="TOR" id="TOR">
    
    </select>
    </div>
    
    
    var x ='<select name="TOR" id="TOR">\n';    
    x +='<option value="MVR Only(FTE)">MVR Only(FTE)</option>\n';
        x += '</select>\n';
        IEFix.innerHTML = x;
    
    0 讨论(0)
  • 2020-12-12 00:32

    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 "<select><option>..."

    0 讨论(0)
提交回复
热议问题