作者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