作者mesak (米沙)
看板Ajax
標題Re: [請問] 這個要怎麼一次只顯示一個
時間Tue Jun 8 14:04:57 2010
※ 引述《knives ()》之銘言:
: ※ [本文轉錄自 EZsoft 看板 #1C3CF9Vh ]
: 作者: knives () 看板: EZsoft
: 標題: [請問] 這個要怎麼一次只顯示一個
: 時間: Mon Jun 7 18:02:46 2010
: <div id="hot_news">
: <p style=" "><a href="http://tw.yahoo.com">第一個</a></p>
: <p style=" "><a href="http://www.google.com.tw">第二個</a></p>
: <p style=" "<a href="http://www.yam.com.tw" >第三個</a></p>
: <p style=" "><a href="http://www.yam.com.tw" >第四個</a></p>
: </div>
: 我的js
: function marquee()
: {
: var container=document.getElementById("hot_news");
: container.appendChild(container.firstChild);
: }
: setInterval("marquee()",3000);
: 這樣子會產生類似跑馬燈的效果
: 但是我要怎麼樣才能夠一次只顯示一個
: 另外如果換用jquery寫要怎麼寫阿
: 謝謝
<script>
$(document).ready(function(){
setTimeout(function(){marquee(0)},1000);
})
function marquee(i){
$('
#hot_news p').hide()
$('
#hot_news p').eq(i).show();
i = (i+1) % $('
#hot_news p').size();
setTimeout(function(){marquee(i)},3000);
}
我不會抓 目前 是 可見的物件,想說要用 each 跑,太累墜了....
乾脆用 time out
※ 編輯: mesak 來自: 123.204.70.172 (06/08 14:08)
1F:→ TonyQ: 用 :visible 就好啦.:p 06/08 20:28