HTML 在 td 中格式化?

HTML Formatting in td?

目前,我的 jQuery AJAX 调用 returns 给我的数据看起来像这样:

<html><p><b>My <i>information</i> here</b></p></html>

所以理论上,它在我的 HTML 页面上应该看起来像这样:

我的信息在这里

但是数据显示的是原始文本而不是程式化的 html(看起来像顶部示例而不是底部示例)。我试图将此信息显示为 tddiv,但似乎都没有正确显示。

是否可以在 tddiv 中显示标签的样式而不是原始文本?

使用 Jquery .html() 如果您的 ajax 调用 return raw html,插入它到你想要 html:

的元素
var htmlString = '<p><b>My <i>information</i> here</b></p>';
$('#element').html( htmlString );

这将插入 html 并且不显示为原始文本

Heres a codepen demo for you