我有些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