0
我有兩個控制顯示內容一前一後
<div id="div1" class="ddd">
For US
</div>
<div id="div2" class="ddd">
For UK
</div>
我想顯示3秒鐘,1區的內容,然後顯示DIV 2項內容3秒,不斷重複這一行爲。這可以在不使用任何otehr插件的情況下完成。可能有兩個以上的控件。
我有兩個控制顯示內容一前一後
<div id="div1" class="ddd">
For US
</div>
<div id="div2" class="ddd">
For UK
</div>
我想顯示3秒鐘,1區的內容,然後顯示DIV 2項內容3秒,不斷重複這一行爲。這可以在不使用任何otehr插件的情況下完成。可能有兩個以上的控件。
像這樣的東西應該工作(假定div的開始編號爲1):
var numControls = 2;
var currentControl = 1;
// Hide all but the first to start with
for (var i = 2; i <= numControls; i++)
$('#div' + i).hide();
setInterval(function()
{
// Hide the old one
$('#div' + currentControl).hide();
// Go to the next one
currentControl++;
if (currentControl > numControls)
currentControl = 1;
// and show it
$('#div' + currentControl).show();
}, 3000);
$(function(){
$(".ddd").each(function(){
setTimeout(function(){ $(this).show(); },3000);
});
});
這是假設他們都共享ddd類,但它應該工作。
這將在3秒後顯示它們放在一起,沒有一個其他的 – Greg 2009-09-24 07:46:16
是的,我想一前一後之後? – Hitz 2009-09-24 07:50:09