jQuery 未捕获的错误:语法错误,无法识别的表达式:#<div/>
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11982184/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught Error: Syntax error, unrecognized expression: #<div/>
提问by Bertjuhh
After updating from jquery 1.5 to 1.8 I get the following error:
从 jquery 1.5 更新到 1.8 后,出现以下错误:
Uncaught Error: Syntax error, unrecognized expression: #<div/>
Updating to 1.7 gives:
Uncaught Error: Syntax error, unrecognized expression: >
Updating to 1.6 no error.
How do I resolve this?
我该如何解决?
Where do I start searching?
我从哪里开始搜索?
Will I have to search in the code for: "<div/>"
?
我是否必须在代码中搜索:"<div/>"
?
EDIT: This is what Chrome tells me: Uncaught Error: Syntax error, unrecognized expression: # base.js:4512
编辑:这就是 Chrome 告诉我的:未捕获的错误:语法错误,无法识别的表达式:# base.js:4512
Sizzle.error base.js:4512
Sizzle.error base.js:4512
tokenize base.js:4785
标记 base.js:4785
Sizzle.compile base.js:4883
Sizzle.compile base.js:4883
select base.js:4973
选择 base.js:4973
select base.js:5083
选择 base.js:5083
Sizzle base.js:3912
嘶嘶声 base.js:3912
jQuery.fn.extend.find base.js:5171
jQuery.fn.extend.find base.js:5171
jQuery.fn.jQuery.init base.js:163
jQuery.fn.jQuery.init base.js:163
jQuery base.js:44
jQuery base.js:44
SysElement.SysElement.Init SysControls.js:1143
SysElement.SysElement.Init SysControls.js:1143
SysElement SysControls.js:1179
SysElement SysControls.js:1179
SysListView.SysListView._ConstructTable WebResource.axd:442
SysListView.SysListView._ConstructTable WebResource.axd:442
SysListView.SysListView._Init WebResource.axd:661
SysListView.SysListView._Init WebResource.axd:661
SysListView WebResource.axd:680
SysListView WebResource.axd:680
(anonymous function) CRMAccounts.aspx:122
(匿名函数)CRMAccounts.aspx:122
Sys$UI$DomEvent$addHandler.browserHandler
Sys$UI$DomEvent$addHandler.browserHandler
回答by codebox
The error seems to be coming from Sizzle, which is used by jquery to handle element selectors such as $('#mydiv')
. It looks like you are using an invalid selector like $('#<div/>')
somewhere. Perhaps you are trying to select a div using its id? - if that is the case then replace <div/>
with the id of the div element. eg
该错误似乎来自 Sizzle,jquery 使用它来处理元素选择器,例如$('#mydiv')
. 看起来您在$('#<div/>')
某处使用了无效的选择器。也许您正在尝试使用其 id 选择一个 div?- 如果是这种情况,则替换<div/>
为 div 元素的 id。例如
<div id="mydiv">blah</div>
$('#mydiv').html('content');
回答by RAK
It might happen that you have accidentally typed any character in between the tag. e.g.,
您可能不小心在标签之间键入了任何字符。例如,
<div"> instead of <div>