textarea 转HTML

Text2Html(str) {
if (str == null) {
return "";
} else if (str.length == 0) {
return "";
}
str =str.replace(new RegExp("\n","gm"),"<br />")
str =str.replace(new RegExp("\r","gm"),"<br />")
 
return str;
}
posted @ 2019-05-29 15:56  羽鱼  阅读(919)  评论(0编辑  收藏  举报