function htmlDecode ( str ) { var ele = document.createElement('span'); ele.innerHTML = str; return ele.textContent; }
例如body下边所有的p标签都防止转义:
$.each($("body").find('p'),function(){ this.innerHTML = htmlDecode(this.innerHTML); });
本文共 341 字,大约阅读时间需要 1 分钟。
function htmlDecode ( str ) { var ele = document.createElement('span'); ele.innerHTML = str; return ele.textContent; }
例如body下边所有的p标签都防止转义:
$.each($("body").find('p'),function(){ this.innerHTML = htmlDecode(this.innerHTML); });
转载于:https://www.cnblogs.com/Basu/p/8252474.html