【发布时间】:2017-08-28 20:38:16
【问题描述】:
我正在尝试从 javascript 打印纯 html,但不知道该怎么做。 示例:
$('#elem').html('This is a normal string'); // --> This is a normal string
$('#elem').html('This <b>contains</b> html')
//Current-> This contains html (contains is bold)
//Wanted-> This <b>contains</b> html
我想这样做是因为我正在使用用户编写的 cmets,并且不希望 html 标签在他们将一些放入他们的 cmets 时应用。但由于其他原因,我需要查看标签。
感谢您的帮助!
【问题讨论】:
-
使用
.text而不是.html!
标签: javascript html