特殊字符转义

xiaoxiao2021-02-28  53

function htmlspecialchars (str) { var str = str.toString().replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"'); return str; } console.log(htmlspecialchars('&jfkds<>'));//"&jfkds<>"
转载请注明原文地址: https://www.6miu.com/read-2623941.html

最新回复(0)