zoukankan      html  css  js  c++  java
  • 批量倒计时(可以参考下思路)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    
    </head>
    <style>
    div{position:relative;height:100px;}
    .the-time{position:absolute;}
    </style>
    <body>
    
    <div><p class="the-time" left_time="2018/9/9">
                                <strong></strong><strong></strong>小时<strong></strong>分钟<strong></strong></p></div>
                              <div><p class="the-time" left_time="2017/11/12">
                                <strong></strong><strong></strong>小时
                                <strong></strong>分钟
                                <strong></strong></p>
                              </div>
                              <div>
                              <p class="the-time" left_time="2016/8/25 17:43:00">
                                <strong></strong><strong></strong>小时
                                <strong></strong>分钟
                                <strong></strong></p>
                              </div>
                              <script>
    function setTimeP(p_class){
        var ps = document.getElementsByTagName("p");
        for(var i = 0; i < ps.length; i ++){
            if(ps[i].className == p_class){
                var aq_time = new Date(ps[i].getAttribute('left_time'));
                var now_time = new Date();
                var end_time = parseInt((aq_time.getTime()-now_time.getTime())/1000);
    //var end_time = parseInt(ps[i].getAttribute('left_time'));
    //sdocument.write(end_time);
                if(end_time > 0){
                    ps[i].end_time = end_time;
                    ps[i].t_ps = ps[i].getElementsByTagName("strong");
                    ps[i].timer = omg;
                    ps[i].timer();
                }else{
                    ps[i].innerHTML = "活动结束";
                    }
            }
        }
    
        function omg(){
            if(this.end_time <= 0 )
              return false
            this.end_time = this.end_time - 1;
            var left_d = Math.floor(this.end_time / 3600 / 24);
            var left_h = Math.floor((this.end_time / 3600)%24);
            var left_m = Math.floor(this.end_time % 3600 / 60);
            var left_s = this.end_time % 3600 % 60;
            this.t_ps[0].innerHTML = "还剩:"+left_d;
            this.t_ps[1].innerHTML = left_h;
            this.t_ps[2].innerHTML = left_m;
            this.t_ps[3].innerHTML = left_s;
            var _this = this;
            setTimeout(function(){_this.timer()}, 1000)
    
        }
    }
    
    </script>
    <SCRIPT LANGUAGE="JavaScript"> 
    setTimeP("the-time");
    </SCRIPT> 
    </body>
    </html>
  • 相关阅读:
    Eclipse配置Maven的本地仓库和阿里云镜像 加速Maven更新
    layui弹出层基础参数
    鼠标悬停设置layui tips提示框
    Java实现文本中的关键字高亮,匹配所有长度
    获取指定格式的系统时间
    截取过长的字符,多余的字符将由省略号代替
    身份证处理方法(15转18,出生日期隐藏)
    layDate面板出现红色花纹图案
    layer单选框 radio的问题总结
    Android--多线程之Handler
  • 原文地址:https://www.cnblogs.com/jxsimon/p/5058718.html
Copyright © 2011-2022 走看看