我覺得我應該能夠從谷歌搜索找到這個,但沒有,所以我會問這裏。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