我觉得我应该能够从谷歌搜索找到这个,但没有,所以我会问这里。if语句可以放在另一个if语句中吗?
我不断收到第二条if语句的错误,所以我想知道是否不允许在预先存在的if/else语句中放置另一个if语句。
感谢您的期待。
function flipImages(){
currentImage = flipArray[i];
if (i == 6) {
clearInterval(interval)
}
else {
// add an opacity animation to the flip so that it is less jarring
// set at a 100ms fade in
$(currentImage).animate({
opacity: 1
}, 100, function() {
console.log(flipArray[i]);
}
// also animate in the child divs of the currentImage (which will only be text on
// the "final" div)
if ($(currentImage).children().hasClass('final'){
$(currentImage).children().animate({
opacity: 1,
left: '+=50'
}, 500, function(){
console.log($(currentImage).children());
});
});
);
i++;
};
}
你有hasClass后失踪)( '最终')。应该是hasClass('final')) – 2013-02-12 16:33:42
这是允许的,你只是有一个语法错误。你错过了')' – 2013-02-12 16:33:51