Javascript 缺失:在属性 ID 之后
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4026271/
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
missing : after property ID
提问by Aaron R
I don't understand what I'm doing wrong here... line 3 is reporting missing : after property ID
我不明白我在这里做错了什么......第 3 行报告丢失:在属性 ID 之后
$(document).ready(function() {
$('#imagegallery img').each(function({$(this).css({ width: '100%'});});
$('#imagegallery').cycle({
timeout: 0,
fx: 'scrollHorz',
width: '100%',
height: 'auto',
next: '.next',
prev: '.prev'
});
$("#imagegallery").touchwipe({
wipeLeft: function() {
$("#imagegallery").cycle("next");
},
wipeRight: function() {
$("#imagegallery").cycle("prev");
}
});
});
回答by user113716
Problem is with this line:
问题出在这一行:
$('#imagegallery img').each(function({$(this).css({ width: '100%'});});
should be:
应该:
// missing ) --------------------v
$('#imagegallery img').each(function(){$(this).css({ width: '100%'});});
Although you can shorten it like this:
虽然你可以像这样缩短它:
$('#imagegallery img').css({ width: '100%'});
回答by Vincent Fan
I also have an error show to definition of my function like below.
我的函数定义也有一个错误显示,如下所示。
function test(a) {
//do something;
}
My case to solve the problem by change it to:
我通过将其更改为解决问题的案例:
test : function(a) {
//do something;
}
The error is gone.
错误消失了。
回答by cwallenpoole
You're missing a close paren in
你错过了一个亲密的父母
// $('#imagegallery img').each(function({$(this).css({ width: '100%'});});
// should be:
$('#imagegallery img').each(function(){$(this).css({ width: '100%'});});
Could that be it?
会是这样吗?
回答by user
This error also shows up when declaring a class method with function
keyword (could have slipped in with copy-pasting):
使用function
关键字声明类方法时也会出现此错误(可能已通过复制粘贴插入):
class T {
function name() {
...
}
}
Should be just:
应该只是:
class T {
name() {
...
}
}
回答by user6809893
The closing parenthesis missing is the each one
缺少的右括号是每个
$('#imagegallery img').each(function({$(this).css({ width: '100%'});});)
Or
或者
$('#imagegallery img').each(function({$(this).css({ width: '100%'});}));