[英]Decode html entities with jquery
How can i decode html entities with jquery like with php function htmlspecialchars_decode? 我如何像php函数htmlspecialchars_decode一样用jquery解码html实体? I have this code:
我有以下代码:
if (jQuery.trim(jQuery("#push_alert").val()) != "") {
alert = jQuery("#push_alert").val();
}
And whenever the text has &
in it, it outputs %amp;
并且只要文本中包含
&
,它就会输出%amp;
Is there a simple way to do it? 有简单的方法吗?
As far i know jQuery itself will give you whatever you entered as a string. 据我所知,jQuery本身会为您提供作为字符串输入的内容。
<textarea id="mytextarea"> a & b</textarea>
$('#mytextarea').keyup(function() {
alert($(this).val())
});
You can provide exact html and jQuery code to investigate further. 您可以提供确切的html和jQuery代码以进一步调查。 Here is jsfiddle : https://jsfiddle.net/0ynm4zf1/
这是jsfiddle: https ://jsfiddle.net/0ynm4zf1/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.