Inserting a newline into a pre tag (IE, Javascript)

前端 未结 11 1889
走了就别回头了
走了就别回头了 2020-12-10 12:34

In IE when I insert text into a

 tag the newlines are ignored:





        
11条回答
  •  没有蜡笔的小新
    2020-12-10 13:03

    If you don't want to use outerHTML, you can also do the following for IE, if an additional pre tag is not an issue:

     if(isIE)
         document.getElementById("putItHere").innerHTML = "
    " + content+"
    "; else document.getElementById("putItHere").innerHTML = content;

提交回复
热议问题