标签:amp bsp IV replace ret str var htm 字符串
function escapeHtml(string) {
var entityMap = {
"&": "&",
"<": "<",
">": ">",
‘"‘: ‘"‘,
"‘": ‘'‘,
"/": ‘/‘
};
return String(string).replace(/[&<>"‘\/]/g, function (s) {
return entityMap[s];
});
}
var string5 = "<div class=‘div2‘ name=‘" + escapeHtml(str1) + "‘>test2222</div>";
标签:amp bsp IV replace ret str var htm 字符串
原文地址:https://www.cnblogs.com/yuki-l/p/9118478.html