Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.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无法识别的表达式错误_Javascript_Jquery_Arrays - Fatal编程技术网

Javascript Jquery无法识别的表达式错误

Javascript Jquery无法识别的表达式错误,javascript,jquery,arrays,Javascript,Jquery,Arrays,我得到这个错误: Error: Syntax error, unrecognized expression: #mas137-0-0-0-1|2|7|9|13 在下面的脚本中。我不明白为什么“ID”不能是“137-0-0-0-1 | 2 | 7 | 9 | 13”。我使用了“|”分隔符,因为如果我使用”、“或”:“,会有其他冲突 $(document.body).on('单击','加载更多文章',函数()){ var ID=$(this.attr(“ID”); 如果(ID){ $(“#mas”

我得到这个错误:

Error: Syntax error, unrecognized expression: #mas137-0-0-0-1|2|7|9|13
在下面的脚本中。我不明白为什么
“ID”
不能是
“137-0-0-0-1 | 2 | 7 | 9 | 13”
。我使用了
“|”
分隔符,因为如果我使用
”、“
”:“
,会有其他冲突

$(document.body).on('单击','加载更多文章',函数()){
var ID=$(this.attr(“ID”);
如果(ID){
$(“#mas”+ID).html(“”);
$.ajax({
键入:“POST”,url:“/show_more.php”,数据:“vid=“+ID,cache:false,
成功:函数(html){
$(“#mas”+ID).remove();
$(“div#posts”).append(html);
}});
}否则{
$(“.masw”).html('-');
}
返回false;
});

您必须转义不被接受的符号。一种方法是

var ID = $(this).attr("id").replace(/\|/g, '\\|');
我仍然建议您对ID属性使用标准的推荐符号

var i=$('div').attr('id').replace(/\\\\\/g,'\\\\\\\'');
var t=$('#mask'+i).text();
警报(t)


Text
所以问题是。。。
var ID = $(this).attr("id").replace(/\|/g, '\\|');