另類跑馬燈基於JQUERY

來源:互聯網
上載者:User
  • 111111111
  • 222222222
  • 333333333
  • 444444444
  • 555555555
  • 666666666
  • 777777777
  • 888888888
  • 999999999
  • aaaaaaaaa
  • bbbbbbbbb
  • ccccccccc
  • ddddddddd
  • eeeeeeeee
  • fffffffff
  • ggggggggg
  • hhhhhhhhh
  • iiiiiiiii
  • jjjjjjjjj
  • kkkkkkkkk
  • lllllllll
  • mmmmmmmmm
  • nnnnnnnnn
  • ooooooooo
  • ppppppppp
  • qqqqqqqqq
  • rrrrrrrrr
  • sssssssss
  • ttttttttt

jquery code:

 

<script language="javascript">
$(document).ready(function(){
    //播放速度
    var speed = 2000;
    //控制範圍
    var block = '#indexLinks li';
    //需要顯示的內容條目數
    var eq = 8;
    var h = 0;
    if($(block).length > eq){//如果內容數目大於需要滾動的數目,開始滾動
        //隱藏除了第一個的其它所有節點
        $(block).slice(eq).css('display','none');
        
        //播放開始
        h = setInterval('scrollContent("'+block+'",'+eq+',2)',speed);  // 多少秒後執行一次函數。附值情況下也會被執行代碼
        $('#siteBulletin').mouseout(function(){
            h = setInterval('scrollContent("'+block+'",'+eq+',2)',speed);
        });
        $('#siteBulletin').mouseover(function(){
            clearInterval(h);
        });
    }
    
});
function scrollContent(block,eq,type){
        //擷取第節點
        var firstNode = $(block);
        //動畫效果
        switch(type){
            case 1:
                animation_out = {height:'hide'};
                animation_in = {height:'show'};
                break;
            case 2:
                animation_out = {opacity:'hide'};
                animation_in = {opacity:'show'};
                break;
            case 3:
                animation_out = {height:'hide',opacity:'hide'};
                animation_in = {height:'show',opacity:'show'};
                break;
            default:'';
        }
        //開始動畫
        firstNode.eq(0).animate(animation_out,1000,function(){//Òþ²Ø
            //複製。追加到最後。隱藏
            $(this).clone().appendTo($(this).parent()).css('display','none');
            //顯示第二個節點內容
            firstNode.eq(eq).removeAttr('style').animate(animation_in,1000);
            //刪除第一個節點內容
            $(this).remove();
        });
}
</script>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.