纯js 原生JavaScript 转义 还原 html标签

function HtmlEncode(text) {
    return text.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>')
}

还原:

function HtmlDecode(text) {
    return text.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>')
}
原文地址:https://www.cnblogs.com/shaoing/p/5358130.html