.InnerHTML Not working properly in Internet Explorer

后端 未结 10 1579
一个人的身影
一个人的身影 2020-12-19 08:55

I wanted to assign a link tag to innerHTML of a HTML control. But this is not working properly in Internet Explorer. However when I try to assign anything other than &

10条回答
  •  萌比男神i
    2020-12-19 09:29

    The thing is it works in FireFox and Google Chrome, but not in IE.

    This is, because you cannot set the innerHTML tag of InternetExplorer with a string, if the string is more than text, ie a HTML element.

    I experienced this trying to dynamically populate a ComboBox into a table cell with AJAX...

    The solution is to use JQuery.
    Then you can do:
    $("#YourElementID").html('

    abc
    ');
    and JQuery will do the DOM stuff, that selbie and KooiInc describe, for you.

提交回复
热议问题