Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/454.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 用jquery解码html实体_Javascript_Jquery_Textarea_Decode - Fatal编程技术网

Javascript 用jquery解码html实体

Javascript 用jquery解码html实体,javascript,jquery,textarea,decode,Javascript,Jquery,Textarea,Decode,如何像使用php函数htmlspecialchars\u decode一样使用jquery解码html实体?我有以下代码: if (jQuery.trim(jQuery("#push_alert").val()) != "") { alert = jQuery("#push_alert").val(); } 当文本中有&时,它输出%amp有简单的方法吗?据我所知,jQuery本身将为您提供以字符串形式输入的

如何像使用php函数htmlspecialchars\u decode一样使用jquery解码html实体?我有以下代码:

                if (jQuery.trim(jQuery("#push_alert").val()) != "") {
                alert = jQuery("#push_alert").val();
            }

当文本中有
&
时,它输出
%amp有简单的方法吗?

据我所知,jQuery本身将为您提供以字符串形式输入的任何内容

<textarea id="mytextarea"> a & b</textarea>
        $('#mytextarea').keyup(function() {
             alert($(this).val())
         });
a&b
$('#mytextarea').keyup(函数(){
警报($(this.val())
});
您可以提供精确的html和jQuery代码来进一步研究。
这是jsfiddle:

检查一下,这与我想要的正好相反