首页 > Web开发 > 详细

jQuery对html进行Encode和Decode

时间:2014-03-19 17:47:32      阅读:438      评论:0      收藏:0      [点我收藏+]

最近需要在前台对编辑器生成的html代码做处理,需要进行编码,考虑到js没有直接对html编码的支持,看了下jQuery的实现,发现真是超级简单呀,顺便记录一下,需要的时候可以参考一下。

```function htmlEncode(value){ if (value) { return jQuery(‘

‘).text(value).html(); } else { return ‘‘; } }

function htmlDecode(value) { if (value) { return $(‘

‘).html(value).text(); } else { return ‘‘; } } ```

jQuery对html进行Encode和Decode,布布扣,bubuko.com

jQuery对html进行Encode和Decode

原文:http://www.cnblogs.com/jasondan/p/3611761.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!