编码HTML实体 [英] Encode HTML entities

查看:100
本文介绍了编码HTML实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在解析feedburner中包含HTML实体的一些数据。我正在尝试使用jQuery对HTML实体进行编码:

I am parsing some data from feedburner of which contains HTML entities. I am trying to encode the HTML entities using jQuery as such:

var encodedStr = data['1']['result']['content']; // content with HTML entities
$("#content").html(encodedStr).text();

但没有结果。

这里是解析的: http://jsbin.com/ihadam/1/edit

推荐答案

基本上你应该将你的html实体编码为html:

Basically you should encode your html entities into html as such:

var encodedStr = data['1']['result']['content'];
var a = $("#content").html(encodedStr).text();

然后获取编码文本并将其应用为html():

Then get the encoded text and apply it as html() as such:

$("#content").html(a);

这应该有效。

演示: http://jsbin.com/ihadam/9/edit

这篇关于编码HTML实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆