我在Chrome和Firefox上测试过,它们都保留换行符,但MSIE不保留。
以下是证据:
这是MSIE或jQuery的错误,还是两者都可以?:)
我在MSIE里连三级警报都收不到...
谢谢:)
发布于 2011-03-01 20:48:20
无论格式如何,IE似乎都会从容器标签的.innerHTML属性中删除换行符(文本节点的.nodeValue属性仍包含原始值):
var div = document.createElement("div");
var t = document.createTextNode("one\ntwo\rthree\r\nfour");
div.appendChild(t);
alert(t.nodeValue);
alert(div.innerHTML);这看起来像是IE的bug:在HTML中,空格必须折叠,但不能完全删除。
https://stackoverflow.com/questions/5148067
复制相似问题