跑马灯效果

8 篇文章 0 订阅
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <link href="css.css" rel="stylesheet" type="text/css" />
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
  
</head>
<div id="siteBulletin">
    <ul id="runtopic">
        <li id="12">人员:姚test 定位时间:adffff</li>
    </ul>
</div>
<input type="button" οnclick="aaa()" value="点击切换" />
<div id="Div1">
    <ul id="Ul1">
        <li id="Li1">人员:test 定位时间:adffff</li>
        <li id="Li2">人员:姚test 1 定位时间:adffff</li>
        <li id="Li3">人员:姚test 32 定位时间:adffff</li>
        <li id="Li4">人员:姚test 4 定位时间:adffff</li>
        <li id="Li5">人员:姚test 5 定位时间:adffff</li>
    </ul>
</div>
<script type="text/javascript">
    function aaa() {
        //克隆.追加到最后.隐藏
        $("#12").animate({ opacity: 'hide' }, 1000, function () {
            $(this).remove();
            $("<li id='12' style='display:none'>开始替换跑马灯</li>").appendTo($("#runtopic"));
            $("#12").removeAttr('style').animate({ opacity: 'show' }, 1000);


        })








    }
    $(document).ready(function () {
        //播放速度
        var speed = 1000;
        //控制范围,符合jQuery路径即可
        var block = '#Div1 li';
        //需要显示的内容条目数
        var eq = 2;
        var h = 0;


        if ($(block).length > eq) {//如果内容数目大于需要滚动的数目,开始滚动!
            //隐藏除了第一个的其它所有节点
            $(block).slice(eq).css('display', 'none');
            //播放开始
            h = setInterval('scrollContent("' + block + '",' + eq + ',1)', speed);
            $('#siteBulletin').mouseout(function () {
                h = setInterval('scrollContent("' + block + '",' + eq + ',1)', 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>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值