打赏

javascript 转义函数

// 字符转义
    html2Escape(sHtml) {
                return sHtml.replace(/[<>&"]/g, function(c) {
                    return {
                        '<': '&lt;',
                        '>': '&gt;',
                        '&': '&amp;',
                        '"': '&quot;'
                    }[c];
                });
            }

 

posted @ 2018-05-08 14:29  孟繁贵  阅读(1860)  评论(0编辑  收藏  举报
TOP