问题描述
从jquery 1.5更新到1.8后,出现以下错误:
After updating from jquery 1.5 to 1.8 I get the following error:
Uncaught Error: Syntax error, unrecognized expression: #<div/>
Updating to 1.7 gives:
Uncaught Error: Syntax error, unrecognized expression: >
Updating to 1.6 no error.
我该如何解决?
我从哪里开始搜索?
我是否必须在代码中搜索:"<div/>"
?
Will I have to search in the code for: "<div/>"
?
这就是Chrome告诉我的内容:未捕获的错误:语法错误,无法识别的表达式:#base.js:4512
This is what Chrome tells me:Uncaught Error: Syntax error, unrecognized expression: # base.js:4512
Sizzle.error base.js:4512
Sizzle.error base.js:4512
tokenize base.js:4785
tokenize base.js:4785
Sizzle.compile base.js:4883
Sizzle.compile base.js:4883
选择base.js:4973
select base.js:4973
选择base.js:5083
select base.js:5083
嘶嘶声base.js:3912
Sizzle 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
(匿名函数)CRMAccounts.aspx:122
(anonymous function) CRMAccounts.aspx:122
Sys $ UI $ DomEvent $ addHandler.browserHandler
Sys$UI$DomEvent$addHandler.browserHandler
推荐答案
错误似乎来自Sizzle,jizz使用该错误来处理元素选择器(例如$('#mydiv')
).似乎您在某处使用了无效的选择器,例如$('#<div/>')
.也许您正在尝试使用其ID选择div? -如果是这种情况,则将<div/>
替换为div元素的ID.例如
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
<div id="mydiv">blah</div>
$('#mydiv').html('content');
这篇关于未捕获的错误:语法错误,无法识别的表达式:#< div/>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!