将 HTML 显示为纯文本 [英] show HTML as plain text

查看:75
本文介绍了将 HTML 显示为纯文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种无需浏览器读取即可将 html 显示为 html 的方法,我找到了 <plainttext> 但是一旦我启动它我就无法阻止它例如:

im looking for a way to show html as html without the browser reading it, i found <plainttext> but once i start it i can't stop it for example:

<plaintext>
    <span> dobeediedabiedadadee olleeeeee</span>
</plaintext>
<h1>hi</h1>

在这个例子中,span 必须显示为文本,h1 显示为标题,但输出是:

in this example the span had to be shown as text and the h1 as a header, but the output is:

    <span> dobeediedabiedadadee olleeeeee</span>
</plaintext>
<h1>hi</h1>

</body>


</html>

这里有一个 JSFiddle 链接:JSFiddle

here a JSFiddle link: JSFiddle

也欢迎使用其他纯文本解决方案感谢您抽出宝贵时间.

a other solution as plaintext is also welcome thanks for your time.

推荐答案

plaintext 早已弃用,只需使用&gt;&lt;

&lt;span&gt; dobeediedabiedadadee olleeeeee&lt;/span&gt;

演示:小提琴

这篇关于将 HTML 显示为纯文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆