jQuery工具错误:未捕获错误:语法错误,无法识别的表达式:[href =/] [英] jquery tools error: Uncaught Error: Syntax error, unrecognized expression: [href=/]

查看:68
本文介绍了jQuery工具错误:未捕获错误:语法错误,无法识别的表达式:[href =/]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将jQuery工具加载到我的网站上.但是Google Chrome控制台显示错误:

I just loaded jQuery Tools onto my site. But the Google Chrome console shows an error:

Uncaught Error: Syntax error, unrecognized expression: [href=/] (http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js)

我正在使用的jQuery版本是1.7.1

The jQuery version I am using is 1.7.1

如何处理此问题?

推荐答案

我假设您有一个选择器,该选择器用于匹配href属性值为/的元素.您需要将/字符放在引号中

I'm assuming you have a selector that is meant to match elements with an href attribute value of /. You will need to put the / character in quotes:

var elems = $("[href='/']");

或者,您可以转义字符:

Alternatively, you can escape the character:

var elems = $("[href=\\/]");

jQuery文档:

如果您希望将任何元字符(例如!"#$%&'()*+,./:;<=>?@[\]^ {|}〜`)用作名称的文字部分,则必须使用两个反斜杠对字符进行转义:\\.

If you wish to use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[\]^{|}~` ) as a literal part of a name, you must escape the character with two backslashes: \\.

这是一个工作示例.删除引号,以产生与您在问题中提到的错误相同的错误.

Here's a working example. Remove the quotes to generate the same error you mention in your question.

这篇关于jQuery工具错误:未捕获错误:语法错误,无法识别的表达式:[href =/]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆