Css--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        .sjc
          {
         font-size: 12px; line-height: 20px;
          }
         .s_time
         {
          }
         .end_time
         {
          }
         .endtime_div
         {
          font-size: 12px; line-height: 20px;
         }
         .endtime_div_hide
         {
          font-size: 12px; line-height: 20px; display:none; color:Red;
          }
         .time_d
         {
          }
       .time_h
        {
        }
       .time_m
        {
         }
       .time_s
       {
        }

jQuery---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- $(".sjc").each(function(){

/*获得开始时间*/
           var x= $(this).children(".s_time").html();
             /*获得结束时间*/
           var x2=$(this).children(".end_time").text();
    
               /*************************倒计时*************************/
      
         //判断活动是否已经过期的函数
          function ck_guoqi(jssj)
          {
              var ck=true;
             var dn_0=new Date();//获得当前时间;
              var dtArr2 = jssj.split("-");
              var dt2 = new Date(dtArr2[0]+"/"+dtArr2[1]+"/"+dtArr2[2]);
              if(dn_0>dt2)
              {
              ck=false;
              }
              return ck;
          }
         if(ck_guoqi(x2))
          {
        
         $(this).parent().next().next().children(".endtime_div_hide").hide();
         var myendtime_div=$(this).parent().next().next().children(".endtime_div").show();
        
         alert(myendtime_div.html());
         time_cha();
         function time_cha()
           {
          //********当前时间*********
         var time_start=new Date().getTime();
//  
          //********结束时间*********
//         var etime=$(this).parent().prev().prev().children().find(".end_time").text();
         var dtArr =  x2.split("-");
         var time_end = new Date(dtArr[0]+"/"+dtArr[1]+"/"+dtArr[2]).getTime();
          // 计算时间差
      var time_distance = time_end - time_start;
       // 天
      var int_day = Math.floor(time_distance/86400000)
      time_distance -= int_day * 86400000;
      // 时
      var int_hour = Math.floor(time_distance/3600000)
      time_distance -= int_hour * 3600000;
      // 分
      var int_minute = Math.floor(time_distance/60000)
      time_distance -= int_minute * 60000;
      // 秒
      var int_second = Math.floor(time_distance/1000)
      // 时分秒为单数时、前面加零
     if(int_day < 10){
   int_day = "0" + int_day;
      }
     if(int_hour < 10){
  int_hour = "0" + int_hour;
      }
     if(int_minute < 10){
  int_minute = "0" + int_minute;
      }
     if(int_second < 10){
  int_second = "0" + int_second;
      }
 // 显示时间
 myendtime_div.children(".time_d").text(int_day);
    myendtime_div.children(".time_h").text(int_hour);
    myendtime_div.children(".time_m").text(int_minute);
    myendtime_div.children(".time_s").text(int_second);
 // 设置定时器
          setTimeout(time_cha,1000);
           }
           }else{
          
           $(this).parent().next().next().children(".endtime_div_hide").show();
           $(this).parent().next().next().children(".endtime_div").hide();
          
           }
          
          
          
           });
div-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 <div style="width: 150px; height: 20px; float: left;">
  <span class="sjc">
  <span class="s_time">2015-11-20</span>
  至<span class="end_time">2015-12-9</span></span>
  </div>
  <div style="width: 40px; height: 20px; float: left; margin-left: 10px;">
    <img src="data:images/lmfwxqy/clock_grey.png" /></div>
  <div style="width: 160px; height: 20px; float: left;">
     <div class="endtime_div">
      <span class="time_d" ></span><span>天</span><span class="time_h"></span><span>时</span><span class="time_m" ></span><span>分</span><span class="time_s" ></span><span>秒</span>
     </div>
     <div class="endtime_div_hide">
      活动已结束!
      </div>
      </div>
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------作为小白编写的第一个js效果

jQuery倒计时的更多相关文章

  1. 20个非常棒的jQuery倒计时脚本

    使用jQuery倒计时插件可能是最简单最好的方式添加动态和交互式倒数计时器到您的网站上.我相信你已经注意到了,例如倒计时功能运行网站,显示倒计时,直到一个大事件.当网站正在维护,告诉用户什么时候回来, ...

  2. jQuery倒计时插件

    倒计时jQuery插件 引言 最近又换工作了,还不错,我换工作的次数其实有点频繁,2014年7月份毕业,到现在工作已经换了3份了,工资跟刚毕业时候相比也涨了点儿,最近一次换工作我离开了深圳,来到了北京 ...

  3. jquery倒计时(仿团购)转至 http://justcoding.iteye.com/blog/2210962

    倒计时一般是用来表示未来某一时刻距现在时刻还剩多少时间.倒计时在WEB上应用非常广泛,如考试系统倒计时,团购网站中的优惠活动倒计时等等.今天,我们来使用jQuery实现一个简单的倒计时功能.

  4. jquery倒计时按钮常用于验证码倒计时

    <!doctype html><html><head> <meta charset="utf-8"> <title>jq ...

  5. jquery 倒计时

    今天让我公司前端大神,李杨哥,给做了一个jquery倒计时功能  很牛逼 看下面的效果图 这个倒计时是需要传值的,看效果代码讲解  百度云盘 ,压缩包永久有效  链接: https://pan.bai ...

  6. jquery倒计时代码

    jquery倒计时代码<pre> <span id="day_show">0天</span> <strong id="hour_ ...

  7. jQuery倒计时组件(jquery.downCount.js)

    //html <span class="days">00</span> <span class="hours">00< ...

  8. Jquery倒计时源码分享

    在静态页添加显示倒计时的容器,并引用下面脚本,代入时间参数即可使用. timeoutDate——到期时间,时间格式为2014/01/01或2014/1/1 D——天 H——小时 M——分钟 S——秒 ...

  9. jQuery倒计时实例

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

随机推荐

  1. Mac下如何配置环境变量

    以前都是在Windows平台上开发,在配置一些框架的时候,为了能够在命令行中调用,一般都会配置bin目录到环境变量中,这是为了让命令行在执行的时候,能够查找到对应的执行文件. 现在工作使用Mac,配置 ...

  2. redis学习之三配置文件redis.conf 的含义

    摘自http://www.runoob.com/redis/redis-conf.html 安装redis之后的第一件事,我就开始配置密码,结果总是不生效,而我居然还没想到原因.今天突然用命令行设置了 ...

  3. 分享在winform下实现左右布局多窗口界面

    在web页面上我们可以通过frameset,iframe嵌套框架很容易实现各种导航+内容的布局界面,而在winform.WPF中实现其实也很容易,我这里就分享一个:在winform下实现左右布局多窗口 ...

  4. 【Swift学习】Swift编程之旅---析构方法(十九)

    在一个类的实例内存被释放之前,析构方法被立即调用.使用deinit关键字来声明析构方法,类似于构造方法用init来声明.析构方法只适用于类类型.   析构方法原理 Swift会自动释放不再需要的实例以 ...

  5. swift3.0的改变

    Swift在这2年的时间内,发展势头迅猛,在它开源后,更是如井喷一样,除了 iOS.mac 平台,还支持了 Linux. 而今年下半年, Swift 3.0 也会随之发布.https://github ...

  6. 利用jstree插件轻松构建树应用

    最近完成了项目中的一个树状应用,第一次接触了jstree这个插件,总的来说它的官方文档还是比较详细的,但是在使用过程中还是出现了一些问题,下面我就来谈谈这款插件的使用和心得. 首先项目需要构建一棵树, ...

  7. java开源时间/日期库Joda-Time

    任何企业应用程序都需要处理时间问题.应用程序需要知道当前的时间点和下一个时间点,有时它们还必须计算这两个时间点之间的路径.使用 JDK 完成这项任务将非常痛苦和繁琐.现在来看看 Joda Time,一 ...

  8. ASP.NET Core 发布至Linux生产环境 Ubuntu 系统

    ASP.NET Core 发布至Linux生产环境 Ubuntu 系统,之前跟大家讲解了 dotnet publish 发布,而没有将整个系统串起来. 今天就跟大家综合的讲一下ASP.NET Core ...

  9. 【C#】递归搜索指定目录下的指定项目(文件或目录)

    ---------------更新:201411201121--------------- 主要更新说明:将原bool recurse参数改为int depth,这样可以指定递归深度,而不是笼统的是否 ...

  10. PostgreSQL类型转换

    1.int装string select CAST (1234 AS text) select to_char(1234,’999‘) 2.string转int select cast('999' as ...