标签:nbsp div hello ace res pat utils ring esc
function htmlEscape(str) {
return String(str)
.replace(/&/g, ‘&‘)
.replace(/"/g, ‘"‘)
.replace(/‘/g, ‘'‘)
.replace(/</g, ‘<‘)
.replace(/>/g, ‘>‘);
}
var path = ‘<div>hello world</div><p> </p>‘;
var res = htmlEscape(path);
console.log(res);
9. js实现java方法:HtmlUtils.htmlEscape()
标签:nbsp div hello ace res pat utils ring esc
原文地址:http://www.cnblogs.com/zkx4213/p/6030486.html