• jquery倒计时代码


    jquery倒计时代码
    <pre>
    <span id="day_show">0天</span>
    <strong id="hour_show">0时</strong>
    <strong id="minute_show">0分</strong>
    <strong id="second_show">0秒</strong>
    </pre>

    <pre>

    timer(50);

    function timer(intDiff) {
    window.setInterval(function() {
    var day = 0,
    hour = 0,
    minute = 0,
    second = 0; //时间默认值
    if (intDiff > 0) {
    day = Math.floor(intDiff / (60 * 60 * 24));
    hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
    minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
    second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
    }
    if (minute <= 9) minute = '0' + minute;
    if (second <= 9) second = '0' + second;
    $('#day_show').html(day + "天");
    $('#hour_show').html('<s id="h"></s>' + hour + '时');
    $('#minute_show').html('<s></s>' + minute + '分');
    $('#second_show').html('<s></s>' + second + '秒');
    //用于毫秒倒计时
    //countdaojishi1('haomiao_show', 99,10);
    intDiff--;
    }, 1000);
    }


    注意haomiao_show是id元素

    function countdaojishi1(obj, startv, endv) {
    var options = {  
     useEasing: false,
      useGrouping: false,
      separator: ',',
      decimal: '.',
    };
    var demo = new CountUp(obj, startv, endv, 0, 2.5, options);
    if (!demo.error) {  
    demo.start();
    } else {  
    console.error(demo.error);
    }
    }


    </pre>

  • 相关阅读:
    gTest&gMock learning
    机器学习 delay learning
    c++ learning
    2017 湘潭邀请赛&JSCPC G&J
    mapreduce&GFS&bigtable learning
    golang learning
    高斩仙的北京历险记
    python learning
    Codeforces Round #448 (Div. 2) B
    python之callable
  • 原文地址:https://www.cnblogs.com/newmiracle/p/11856361.html
Copyright © 2020-2023  润新知