本文介绍了如何在javascript中转义一些html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于文字

<b>This is some text</b>

我想将它写入我的页面,以便它显示如下:

I want to write it to my page so that it shows up like this:

< b>这是一些文字< / b>

而且不喜欢这个

这是一些文字

使用 escape(< b>这是一些文字< / b>)在firefox中给了我这个可爱的宝石

using escape("<b>This is some text</b>") gives me this lovely gem in firefox

%3Cb%3EThis%20is%20some%20text%3C/b%3E



not exaclty what I'm after. Any ideas?

推荐答案

这应该适合你:用于指出这种情况。从。

Thanks to buffer for pointing out this case. Snippet taken out of this blog post.

这篇关于如何在javascript中转义一些html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 12:46
查看更多