// 字符转义 function html2Escape(sHtml) {
return sHtml.replace(/[<>&"]/g, function(c) {
return {
'<': '<', '>': '>', '&': '&', '"': '"' }[c]; }); }
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/202788.html原文链接:https://javaforall.net
JS转义字符字符转义 functionhtml sHtml returnsHtml replace lt gt amp g function c return lt lt gt gt amp
// 字符转义 function html2Escape(sHtml) {
return sHtml.replace(/[<>&"]/g, function(c) {
return {
'<': '<', '>': '>', '&': '&', '"': '"' }[c]; }); }
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/202788.html原文链接:https://javaforall.net