我目前有位於一個ul
標籤爲li
的縮略圖列表。jQuery的 - 每個功能
我現在用的是Galleria圖片庫,但我有我的畫廊超過六幅圖像,所以我在想實現一個網頁系統。
我所試圖做的是以下幾點:
我有圖片,row1
的一排,當你點擊2 row1
頁面上應該隱藏使用此功能hide("slide")
,畢竟他們都躲在,row2
應顯示使用show("slide")
,但發生在同一時間,這些hide
和show
功能,我想hide
功能來完成show
函數執行之前,這裏是我的代碼:
$("a[href^='#']").click(function() {
if (($(this).attr("href") == "#") && ($(this).attr("rel") != "gallery") && ($(this).attr("href").indexOf("row") < 0)) {
return false;
}
else if ($(this).attr("href").indexOf("row") < 0) {
$.scrollTo($(this).attr("href"),1000);
return false;
} else {
var href = $(this).attr("href");
href = href.replace("#","");
$("ul.galleria li").each(function() {
if ($(this).is(":visible")) {
$(this).hide("slide");
}
}).;
$("ul.galleria li."+href).each(function() {
$(this).show("slide", 800);
});
return false;
}
});
如何在show函數等待繼續時執行hide函數?
//編輯
我已經改變了我的代碼如下:
$("ul.galleria li:visible").hide("clip", {direction : "horizontal"},function(){
$("ul.galleria li."+href).show("clip", {direction : "horizontal"}, 800);
});
但現在,展會功能運行完全一樣的li
的,這是上可見數的次數之前的'頁面'。我怎樣才能讓這個函數只執行一次?
謝謝,這正是我想要的,但是'show'功能究竟執行了六次,你有什麼想法,爲什麼? – 2009-12-19 08:39:33
你可能需要放一個stop(),因爲它建立了一個隊列(你有六個可見元素吧?)。我會更新代碼。 – pixeline 2009-12-19 15:04:13