Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/447.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/jquery/84.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 带有特殊字符的Optgroup筛选_Javascript_Jquery - Fatal编程技术网

Javascript 带有特殊字符的Optgroup筛选

Javascript 带有特殊字符的Optgroup筛选,javascript,jquery,Javascript,Jquery,我明白了: var branches = $('#branch_name').html(); var filtrate = optgroup[label="Abe's Milk"] var options = $(branches).filter(filtrate).html(); 但如果我说: throw new Error ( "Syntax error, unrecognized expression: " + msg ); 没有错误 我尝试用正则表达式自动转义Abe的单引号,但也失败

我明白了:

var branches = $('#branch_name').html();
var filtrate = optgroup[label="Abe's Milk"]
var options = $(branches).filter(filtrate).html();
但如果我说:

throw new Error ( "Syntax error, unrecognized expression: " + msg );
没有错误

我尝试用正则表达式自动转义Abe的单引号,但也失败了,因为没有optgroup匹配Abe的Milk

请帮忙。谢谢

我试着用一个字母自动地转义Abe的一句话 正则表达式,但这也失败了,因为没有optgroup 配上阿贝的牛奶

尝试:


听起来您在jQuery中发现了一个bug。看看你是否能用最新版本复制它。如果不能:升级。如果可以:提交错误报告。jQuery源代码在GitHub上,考虑分叉它,修复bug并发出pull请求。看起来我需要在我的文本输入中做一些输入限制来暂时解决这个问题。
var filtrate = optgroup[label="Abes Milk"]
optgroup[label="Abe\'s Milk"]