【发布时间】:2010-07-27 05:02:34
【问题描述】:
我遇到了一个在文本区域中解析回车的小问题。
JQuery 代码
$.fn.escapeHtml = function() {
this.each(function() {
$(this).html(
$(this).html()
.replace(/"/g,""")
.replace(/&/g,'&')
.replace(/</g,'<')
.replace(/>/g,'>')
.replace(/'/g,''')
// For converting carrage return (enter key) to br
.replace(/(\r\n|\r|\n)/g, '< br >')
.replace(/183/g,'·')
);
});
return $(this);
}
})(jQuery);
在 Firefox 中它可以工作并且输出为
<big>Heading</big><br>Test Line 1<br>Test Line 2<br>Test Line 3
在 Internet Explorer 中它根本不起作用。我如何在 IE 中解决这个问题。我的意图输出是这样的
<big>Heading</big><br>Test Line 1<br>Test Line 2<br>Test Line 3
提前谢谢...
【问题讨论】:
标签: javascript jquery regex parsing jquery-plugins