javascript 如何将 html 特殊字符转换为普通 HTML?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11848726/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to convert html special chars to ordinary HTML?
提问by Ivan Gromov
Possible Duplicate:
How to decode HTML entities using jQuery?
HtmlSpecialChars equivalent in Javascript?
可能的重复:
如何使用 jQuery 解码 HTML 实体?
Javascript 中的 HtmlSpecialChars 等价物?
I need to convert with escaped htmlspecialchars to a valid HTML code, for example:
我需要使用转义的 htmlspecialchars 转换为有效的 HTML 代码,例如:
<p>Text here</p>
should be displayed in the browser like
应该在浏览器中显示
Text here
在这打字
What is the right way to do that?
这样做的正确方法是什么?
Thanks in advance, Ivan.
提前致谢,伊万。
采纳答案by Ivan Gromov
How to decode HTML entities using jQuery?and jQuery .appendTo
method worked for me.
如何使用 jQuery 解码 HTML 实体?和 jQuery.appendTo
方法对我有用。
回答by Oliver Spryn
Try the PHP.JS function to perform this action. Their examples solve exactly the question you are asking:
尝试使用 PHP.JS 函数来执行此操作。他们的例子正好解决了你问的问题: