Why does IE give unexpected errors when setting innerHTML

后端 未结 10 2766
面向向阳花
面向向阳花 2020-12-10 17:20

I tried to set innerHTML on an element in firefox and it worked fine, tried it in IE and got unexpected errors with no obvious reason why.

For example if you try and

10条回答
  •  一向
    一向 (楼主)
    2020-12-10 18:00

    Have you tried setting innerText and/or textContent? Some nodes (like SCRIPT tags) won't behave as expected when you try to change their innerHTML in IE. More here about innerText versus textContent:

    http://blog.coderlab.us/2006/04/18/the-textcontent-and-innertext-properties/

提交回复
热议问题