[英]Regex selector for jquery does not work. Why?
我正在尝试使用此方法,但没有成功。 我在FFv47
我尝试调试(F12)并停止脚本执行:
return regex.test(jQuery(elem)[attr.method](attr.property));
当我输入监视表达式时: jQuery(elem)[attr.method](attr.property)
我看到undefined
当我输入监视表达式时: jQuery(elem)[attr.method]('class')
我看到了'editor'
(按预期)
当我输入监视表达式时: attr.property
我看到'class'
因此,我希望第一只手表的表情有效,并向我展示'editor'
价值
为什么jQuery(elem)[attr.method](attr.property)
没有显示正确的值?
在指定的博客文章错误。 您应该替换为:
regex = new RegExp(matchParams.join('').replace(/^s+|s+$/g,''), regexFlags);
通过这个(Notice \\
near s+
)
regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
编写选择器时也要小心:
$('script:regex( src,jQuery)');
如果您偶尔在示例_src
(在此将_
为空格)上方放置额外的空间,则将测试该属性,而不是预期的src
。
这也可能是导致错误的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.