jQuery .html显示html标签,而不是在文本上应用html标签 [英] jquery .html shows html tags instead of applying html tags on the text
本文介绍了jQuery .html显示html标签,而不是在文本上应用html标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码是
printMsg : function(data) {
$("#message").html(data.bodyText);
...
}
此处
data.bodyText = <strong> Test This Text ;/strong>
我想将数据显示为测试此文本&为此,我做到了
I am suppose to display data as Test This Text & for that I did
$("#message").html(data.bodyText);
这在jquery先前版本(1.9)中正确显示了文本
This displayed the text correctly with jquery previous versions (1.9)
现在使用jquery 1.10显示
Now with jquery 1.10 it displays
<strong> Test This Text </Strong>
您能告诉我原因吗? &有什么解决办法吗?
Can you please tell me reason for this? & any solution if you have?
推荐答案
您是否正在尝试执行这?一个> 在jquery 1.10.1中似乎正常工作
are you trying to do something like this? in jquery 1.10.1 it seems work normally
HTML
<span id='message'></span>
JS
var data = {};
data.bodyText = "<strong>Test This Text;</strong>";
$("#message").html(data.bodyText);
这篇关于jQuery .html显示html标签,而不是在文本上应用html标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文