📜  html转义函数javascript代码示例

📅  最后修改于: 2022-03-11 15:04:31.545000             🧑  作者: Mango

代码示例2
function escapeHTML(text) {  
    var replacements= {"<": "<", ">": ">","&": "&", """: """};                      
    return text.replace(/[<>&"]/g, function(character) {  
        return replacements[character];  
    }); 
}