2010-10-30 17 views
0

那麼,繼承人是什麼意思。在jQuery中循環的問題

Go to site

它說最新的消息,有一些問題。

我想要做的是:。

裝載場,看到加載條(圖片是在HTML)的加載條消失了,那裏有一個段落,在淡出

那這是什麼。

// Hides the loading image and fadesin content 
    var $latest = $(".latest") 
    $latest 
    .hide(); // Hide Content 
    setTimeout(function(){ 
    $('#loading') 
     .hide(); 
    $latest.fadeIn(); 
    } 
    , 3000); 

現在,我還想要做的就是隱藏段落,淡入另一個,然後是那個。然後重新啓動並重新循環。

那是什麼這是:

$latest 
    .hide() 
    .first() 
    .show(); 

    refreshId = setInterval(function() { 
    next = $(".latest:visible").next(); 
    if (next.length) { 
    $latest.hide(); 
    next.fadeIn(); 
    } else { 
    $(".latest") 
    .hide() 
    .first() 
    .fadeIn(); 
    } 
    }, 3000); 

正如你所看到的,海誓山盟整個事情的兩個腳本衝突都瘋了(這和形象繼續出現)。有沒有辦法解決它?

回答

1

試試這個:

setTimeout(function() { 
    $('#loading').hide(0,rotator); 
}, 3000); 

function rotator() { 
    var $paragraphs = $('#latest-news').find('p.latest'); // the paragraphs 
    $paragraphs.first().show(); 
    var i = 0; 
    var looper = setInterval(function() { 
    var showpara = i++ % $paragraphs.length; // choose next one to show 
    $paragraphs.not(':eq(' + showpara + ')').hide() // hide others 
     .end() // back to first selector 
     .eq(showpara).fadeIn(); // show the next 
    }, 3000); 
} 


編輯:更新後處理負荷消息,在函數封裝轉子,當加載消息被隱藏觸發該功能。

+0

每個循環後圖像仍然顯示 – omnix 2010-10-30 20:34:54

+0

您希望加載圖形只顯示一次嗎?或者在每個段落之間透露? – 2010-10-30 22:48:52

+0

只有一次.... ,,,, – omnix 2010-10-30 23:11:24