有人能告诉我为什么return false
不工作?我只想检查电流是否是黄色。如果是黄色课,不要做任何事(返回false)。问题是当你点击一个按钮时,它会再次运行它,但我想避免这种情况。 Here's the Fiddle of the problem。返回假不工作
/*INSIDE THIS CODE RETURN FALSE NOT WORKING!!*/
$('.yellowcontroll').click(function(){
if($yellow.after('.current').length){
$('.yellow').show();
$('.slideswrapper:not(:animated)').animate({'marginLeft':'-=100'},1000,function(){
$('.current').removeClass('current').hide();
$('.yellow').addClass('current');
$('.slideswrapper').css({'margin-left':'0px'});
if($('.current').is($('.slideswrapper div:last'))){
$('.blue,.green,.red').clone().insertAfter('.slideswrapper div:last');
}
if($('.current').is($('.red'))){
$('.red').prevAll().remove(':not(.yellow)');
$('.yellow').insertAfter($('.slideswrapper div:last'));
}
/*THIS IS NOT WORKING AS EXPECTED!!*/
if($('.current').is($('.yellow'))){
return false;
}
});
}
});
您是否尝试过在那里你期待返回一个错误的行中添加的console.log()?它是否达到了你的代码的那一部分? – 2012-04-10 17:05:03
在发布之前请格式化您的代码,以便我们更容易阅读和理解。 – 2012-04-10 17:12:07