百度地图API首页数字动态改变特效jquery特效

百度地图API首页数字动态改变特效

百度地图首页板块

1.昨天做网站领导需要一个浏览器窗口滚动到当前位置数字开始变动到指定位置,现在我把代码分享给大家。

代码片段html

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            height: 2000px;
            border-bottom:5px solid red;
        }
        .wrap{
            width:1200px;
            margin:30px auto;
        }
        .wrap p{
            width:200px;
            float:left;
            margin:0 50px;
            font-size:50px;
            color:#ff6700;
        }

    </style>
</head>

<body>
    <div class="box"></div>
    <div class="wrap">
        <p>
            <strong class="serve">0</strong>亿
        </p>
        <p>
            <strong class="percent">0</strong>%
        </p>
        <p>
            <strong class="web">0</strong></p>
        <p>
            <strong class="person">0</strong></p>
    </div>
    <div class="box"></div>
    <!-- <script src="jquery-1.12.4.min.js"></script> -->
    <script src="jquery-1.8.3.min.js"></script>
    <script>
        $(function(){
            $(window).scroll(function(){
                var sctop = $(window).scrollTop();
                if($('.wrap').offset().top  - sctop < 500){
                    console.log(1)
                    $('.serve').animate({count:1200},{queue:true,duration:2000,step:function(now,fx){
                        // console.log(now,fx)
                        var num = parseInt(now).toString().replace(/(?=(\B)(\d{3})+$)/g,',')
                        $('.serve').text(num)
                    }})

                    $('.percent').animate({count:75},{queue:true,duration:2000,step:function(now,fx){
                        // console.log(now,fx)
                        var num = parseInt(now).toString()
                        $('.percent').text(num)
                    }})

                    $('.web').animate({count:65},{queue:true,duration:2000,step:function(now,fx){
                        // console.log(now,fx)
                        var num = parseInt(now).toString()
                        $('.web').text(num)
                    }})

                    $('.person').animate({count:165},{queue:true,duration:2000,step:function(now,fx){
                        // console.log(now,fx)
                        var num = parseInt(now).toString()
                        $('.person').text(num)
                    }})
                }
            })
        })
    </script>
</body>

</html>

下面给大家放上js下载地址:http://www.hj1992.com/js/jquery-1.8.3.min.js

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值