JavaScript innerHTML is not working for IE?

后端 未结 3 1631
我寻月下人不归
我寻月下人不归 2020-11-30 12:49

I am using ajax call for to bring the list for my drop down and assign it to html,works fine for mozilla nad crome but for IE it displays a blank dropdown

v         


        
3条回答
  •  生来不讨喜
    2020-11-30 13:38

    The innerHTML property has some problems in IE when trying to add or update form elements, the workaround is to create a div and set the innerHtml property on that before appending to the DOM:

    var newdiv = document.createElement("div");
    newdiv.innerHTML = xmlhttp.responseText;
    var container = document.getElementById(id);
    container.appendChild(newdiv);
    

提交回复
热议问题