使用jquery显示html标记

使用jquery显示html标记,jquery,Jquery,我得到了以下json: {"results":[{"id":"1","title":"Hello","content":"Hello<br>world"}]} {“results”:[{“id”:“1”,“title”:“Hello”,“content”:“Helloworld”}]} 数据可以通过以下方式成功显示 $('<td class="a">').html(res.id), $('<td class="b">').html(res.title),

我得到了以下json:

{"results":[{"id":"1","title":"Hello","content":"Hello<br>world"}]}
{“results”:[{“id”:“1”,“title”:“Hello”,“content”:“Hello
world”}]}
数据可以通过以下方式成功显示

$('<td class="a">').html(res.id),
$('<td class="b">').html(res.title),
$('<td class="c">').html(res.content),
$('').html(res.id),
$('').html(res.title),
$('').html(res.content),
唯一的问题是我也想显示

标记。jquery中是否有任何函数可以帮助我显示html标记?

是的,您可以使用:

我们需要注意的是,这个方法会转义所提供的字符串 这是必要的,以便它能够以HTML格式正确呈现。要做到这一点,它需要 DOM方法
.createTextNode()
,不会将字符串解释为 HTML

$('').text(res.id);
$('').text(res.title);
$('').text(res.content);
$('<td class="a">').text(res.id);
$('<td class="b">').text(res.title);
$('<td class="c">').text(res.content);