【问题标题】:jquery convert HTML code to plain text [duplicate]jquery将HTML代码转换为纯文本[重复]
【发布时间】:2015-01-03 21:07:50
【问题描述】:

我正在做一个聊天应用程序。当我发布一个 html 代码时,它会给出执行的 HTML

例如,如果我发布为:

<i><h1>welcome</h1></i>        

输出为

欢迎

但我需要像输入一样的输出。实际输出应该是

<i><h1>welcome</h1></i>

谁能帮帮我。谢谢提前,,,

【问题讨论】:

标签: jquery html chat


【解决方案1】:

你应该使用pre标签:-

<pre><i><h1>welcome</h1></i></pre>

Link

【讨论】:

    【解决方案2】:

    $("div").text("test");这就是你要找的。​​p>

    您可以使用 .text() 转义 html 字符。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-24
      • 2017-03-20
      • 2016-02-04
      • 2021-08-29
      相关资源
      最近更新 更多