js Html结构转字符串形式显示代码
代码如下:
//Html结构转字符串形式显示 支持<br>换行 function ToHtmlString(htmlStr) { return toTXT(htmlStr).replace(/\<\;br[\&ensp\;|\&emsp\;]*[\/]?\>\;|\r\n|\n/g, "<br/>"); } //Html结构转字符串形式显示 function toTXT(str) { var RexStr = /\<|\>|\"|\'|\&| | /g str = str.replace(RexStr, function (MatchStr) { switch (MatchStr) { case "<": return "<"; break; case ">": return ">"; break; case "\"": return """; break; case "'": return "'"; break; case "&": return "&"; break; case " ": return " "; break; case " ": return " "; break; default: break; } } ) return str; }
相关推荐
STPace 2016-04-27
zjnig的信息仓库 2019-04-30
yuanlintufang 2016-04-27
hong 2015-12-28
yesbuy00 2014-07-23
辣m精彩 2014-01-22
niehanmin 2013-11-26
zwq 2013-04-11
黎豆子 2012-10-29
WinerChopin 2012-06-05
lovehuayud 2012-02-22
别告诉我有Bug 2011-09-22
zhangpeng 2011-03-29
zwq 2011-03-05
xdyangxiaoromg 2019-05-09
heicxsudoblog 2019-05-08