遗失:属性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"); } }); });
问题在于这一行:
$('#imagegallery img').each(function({$(this).css({ width: '100%'});});
应该:
// missing ) --------------------v $('#imagegallery img').each(function(){$(this).css({ width: '100%'});});
虽然你可以像这样缩短它:
$('#imagegallery img').css({ width: '100%'});
我也有一个错误显示定义我的function,如下所示。
function test(a) { //do something; }
我的情况是通过改变它来解决问题:
test : function(a) { //do something; }
错误消失了。
你错过了一个亲密的人
// $('#imagegallery img').each(function({$(this).css({ width: '100%'});}); // should be: $('#imagegallery img').each(function(){$(this).css({ width: '100%'});});
可能是吗?
缺少右括号是每一个
$('#imagegallery img').each(function({$(this).css({ width: '100%'});});)
要么
$('#imagegallery img').each(function({$(this).css({ width: '100%'});}));