我有些jQuery的打算在這裏:jQuery的挑選下一格在列表中顯示
$('#ticker1').hide();
$('#ticker2').hide();
$('#ticker3').hide();
$("#ticker").oneTime(2000,function(i) { /* Do the first pull out once */
var randomNum = Math.floor(Math.random()*3); /* Pick random div to show */
$('div#ticker div:eq(' + randomNum + ')').show();
$("#ticker").animate({right: "0"}, {duration: 800 });
});
$("#ticker").oneTime(20000,function(i) { /* Do the first retract once */
$("#ticker").animate({right: "-450"}, {duration: 800});
$("#ticker").oneTime(1000,function(i) {
$('#ticker1').hide();
});
});
$("#ticker").everyTime(21500,function(i) { /* Everytime timer gets to certain point */
var randomNum = Math.floor(Math.random()*3);
$('div#ticker div:eq(' + randomNum + ')').show();
$("#ticker").animate({right: "0"}, {duration: 800}); /* Pull out right away */
$("#ticker").oneTime(20000,function(i) { /* Retract once */
$("#ticker").animate({right: "-450"}, {duration: 800});
});
$("#ticker").oneTime(21000,function(i) { /* Hide all divs once */
$('#ticker1').hide();
$('#ticker2').hide();
$('#ticker3').hide();
});
});
我試圖得到它顯示一個隨機div的,第一次翻出,這在已經完成代碼的第一部分。但之後,我現在每次都抓取一個隨機div(3個div)。我需要更改這部分代碼,以便查看3個div的列表,並且每次都會下一個。
因此,如果第一次拉出格爲2那之後每次會在這個順序去:DIV 3,1區,2區,3 DIV,DIV 1等
這裏是一個現在正在發生的事情的演示:treethink.treethink.net/backup
感謝, 韋德
爲什麼你在不使用'this'的情況下使用oneTime?使用setTimeout。另外,查看jQuery動畫回調。 – 2010-02-06 01:30:18