zoukankan      html  css  js  c++  java
  • 关于秒杀倒计时按钮的方法

     function Load() {
        var stringTime = "2020-06-24 11:20:00";
        var timestamp2 = Date.parse(new Date(stringTime));
        timestamp2 = timestamp2 / 1000;  //获取到的 格式日期 的时间戳
        var myDate = new Date();
        var timestamp = myDate.getTime()/1000;  //当前时间戳 获取的时间戳为毫秒 需除1000
        timestamp = timestamp.toFixed();
        //过了某时间 直接不可点
        var stringTime3 = "2020-06-24 20:02:00";
        var timestamp4 = Date.parse(new Date(stringTime3));
        timestamp4 = timestamp4 / 1000;  //获取到的 格式日期 的时间戳
        if(timestamp>timestamp4){
            alert('活动已结束');
            return;
        }
        if(timestamp>timestamp2 && timestamp<timestamp4){
            $("#btn").val("快抢").removeAttr("disabled");
            return;
        }
        var count = timestamp2 - timestamp;
        var countdown = setInterval(CountDown, 1000);
            function CountDown() {
                $("#btn").val("离活动开始还有" + count + "秒");
                if (count == 0) {
                    $("#btn").val("快抢").removeAttr("disabled");
                    clearInterval(countdown);
                }
                count--;
            }
        }
        Load();
  • 相关阅读:
    spring(三):ApplicationContext
    android Xutils dbutils 注解
    android 录音的断点续传
    android 原生dialog对话框
    android asyncTask 详解
    自定义的dialog
    fragment 添加menu
    android baseApplication 基类
    看项目得到info_freeCsdn-01闪屏页面
    开源项目 github
  • 原文地址:https://www.cnblogs.com/sange118/p/13196027.html
Copyright © 2011-2022 走看看