Jquery:错误:语法错误,无法识别的表达式:[name=someVar]
足够简单的代码:
$("meta[name=DCSext.Level]")
错误:
Error: Syntax error, unrecognized expression: [name=DCSext.Level]
我在 Jquery 中从 1.4.2 升级到 1.7.1。显然它在 1.4.2 中仍然有效。
有什么想法吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
语法应为 ">jQuery API。我建议在 JS 中对字符串使用单引号,这样您就不必转义双引号,我更喜欢在 HTML 中使用双引号:
尽管您可以继续使用双引号:
并且您可以交换引号用法:
这全部当然假设属性本身如下:
如果 DCSext 是 JS 对象,则需要将其连接到字符串中:
The syntax should be
[name="DCSext.Level"]
as specified in the jQuery API. I recommend using single quotes for strings in JS so that you don't have to escape double-quotes, which I prefer to use for HTML:Although you could continue to use double quotes:
And you could swap the quote usage:
This all of course assumes that the attribute itself is as follows:
If DCSext is a JS object, you'll need to concatenate it into the string:
如果它是字符串,则应该添加引号:
或者如果它是变量:
You should add quotes if it is string:
Or if it is variable:
或者如果 DCSext.Level 是变量:
or if DCSext.Level is a variable: