admin管理员组文章数量:1325550
Often ( too often ) I get this error in chrome console. I really can't find any syntacs error in my javascript code
When I try to locate where this error happen in google chrome, it always shows this:
It shows that error is on the beginning of the file ( somewhere around DOCTYPE ). Is this just that chrome doesn't show more infos or I messed up with inclusion of the files somewhere? ( or maybe even syntacs? ). Either way, I can't locate it with help of debug console
this is global.js:
(function() {
$("#btadd").click(function() {
$(".newlist").slideUp();
return false;
});
})();
this is html:
<div class="newlist" style="display:none">
<h4>Title: <input type="text"/></h4>
</div>
<br />
<a href="javascript:void()" id="btadd"><span>Add New</span></a>
Often ( too often ) I get this error in chrome console. I really can't find any syntacs error in my javascript code
When I try to locate where this error happen in google chrome, it always shows this:
It shows that error is on the beginning of the file ( somewhere around DOCTYPE ). Is this just that chrome doesn't show more infos or I messed up with inclusion of the files somewhere? ( or maybe even syntacs? ). Either way, I can't locate it with help of debug console
this is global.js:
(function() {
$("#btadd").click(function() {
$(".newlist").slideUp();
return false;
});
})();
this is html:
<div class="newlist" style="display:none">
<h4>Title: <input type="text"/></h4>
</div>
<br />
<a href="javascript:void()" id="btadd"><span>Add New</span></a>
Share
Improve this question
edited Feb 16, 2013 at 17:16
Alexim
asked Feb 16, 2013 at 17:10
AleximAlexim
811 silver badge5 bronze badges
3
- 1 You'll need to post some code or an example. – j08691 Commented Feb 16, 2013 at 17:12
- 3 The SyntaxError won't be your DOCTYPE - go through your JavaScript – hohner Commented Feb 16, 2013 at 17:13
- code added , this is basically all I have – Alexim Commented Feb 16, 2013 at 17:18
2 Answers
Reset to default 5I had a similar problem. The error could also e from
javascript:void();
which should actually be
javascript:void(0);
You can reproduce this error in your console with
void()
Change this:
(function() {
$("#btadd").click(function() {
$(".newlist").slideUp();
return false;
});
})();
to this:
$(function () {
$("#btadd").click(function () {
$(".newlist").slideUp();
return false;
});
});
Or move your existing JavaScript to the end of the body. You created a self-invoking anonymous function that's executing before the elements it applies to have been loaded. This would work fine once the DOM is fully loaded, but since it's in the head of your document it runs too early. By using the example I showed you you're using jQuery's document ready event to run the code.
本文标签: jqueryUncaught SyntaxError Unexpected token ) javascript in chromeStack Overflow
版权声明:本文标题:jquery - Uncaught SyntaxError: Unexpected token ) javascript in chrome - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742193353a2430622.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论