javascript 实现htmlEncode htmlDecode


屌屌的写法。。

function htmlEncode(value){ //create a in-memory div, set it's inner text(which jQuery automatically encodes) //then grab the encoded contents back out. The div never exists on the page. return $('<div/>').text(value).html(); } function htmlDecode(value){ return $('<div/>').html(value).text(); }
posted @ 2016-10-27 15:31  调调儿  阅读(1581)  评论(0编辑  收藏  举报