0
我有一個定期那種追加從「前高後低」的項目後:jQuery的動畫功能已禁用排序從高到低
library.sort(function(a, b) { return a.year - b.year; });
upperlimit = library.length-1
for (i=upperlimit; i<library.length; i=i-1){
//source.sort(function(a, b) { return a.year - b.year; });
item = "<div class='item' style='background-image:url(" + library[i].source + ");' ><h2>" + library[i].title + "</h2></div>"
$("#list").append(item);
}
但是,因爲它是從「前高後低」追加,它在某種程度上禁用此其它功能:
$(".item h2").css({"bottom":"-135px"});
$(".item").hover(
function(){
$(this).find("h2").animate({"bottom":"-85px"},300)
},
function(){
$(this).find("h2").animate({"bottom":"-135px"},150)
}
);
然而,當它被寫入到從 '低到高' 追加,
for(i=0; i<library.length; i=i+1)
有生瓦特orks罰款。在Firebug上,當寫成'high to low'時,它會顯示一個錯誤「TypeError:library [i]未定義」,但是沒有錯誤發生,從'低到高'。
對於這兩種情況,一切都顯示正常(圖像和隱藏h2),但它只是在'高到低'不起作用的動畫。
我明白了!這樣可行。太棒了,凌晨4點工作對我來說並不聰明。 – user1299248