zoukankan      html  css  js  c++  java
  • 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>

  • 相关阅读:
    常用软件整理列表
    红黑树的旋转(C语言)
    Linux 内核编译
    2017年9月11日
    2017年 9月10日
    2017年9月8号 开学第一天
    开始学习.net的第二天
    前端工作需要什么
    Kubernetes容器编排技术---Kubernetes基本概念和术语(一)
    监控工具之---Prometheus探索PromQL(二)
  • 原文地址:https://www.cnblogs.com/newmiracle/p/11856361.html
Copyright © 2011-2022 走看看