js中特殊转换字符为html标签 Posted 2020-11-01 ppjj tags: 篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js中特殊转换字符为html标签相关的知识,希望对你有一定的参考价值。 function htmlEncode(text){ return text.replace(/&/g,‘&‘).replace(/\"/g,‘"‘).replace(/</g,‘<‘).replace(/>/g,‘>‘); }