找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 1703|回复: 0

简单的倒计时代码特效jQuery

[复制链接]
发表于 2015-7-9 22:06:07 | 显示全部楼层 |阅读模式
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset=utf-8 />
  5. <title>jquery版的网页倒计时效果</title>
  6. <!--[if IE]>
  7. <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  8. <![endif]-->
  9. <style>
  10.   .time-item strong{background:#C71C60;color:#fff;line-height:49px;font-size:36px;font-family:Arial;padding:0 10px;margin-right:10px;border-radius:5px;box-shadow:1px 1px 3px rgba(0,0,0,0.2);}
  11. #day_show{float:left;line-height:49px;color:#c71c60;font-size:32px;margin:0 10px;font-family:Arial, Helvetica, sans-serif;}
  12. .item-title .unit{background:none;line-height:49px;font-size:24px;padding:0 10px;float:left;}
  13.   h1{font-family:"微软雅黑";font-size:40px;margin:20px 0;;border-bottom:solid 1px #ccc;padding-bottom:20px;letter-spacing:2px;}
  14. </style>
  15. <script src="http://www.codefans.net/ajaxjs/jquery-1.7.2.min.js" type="text/javascript"></script>
  16. <script type="text/javascript">
  17.         var intDiff = parseInt(200000);//初始日期
  18.         function timer(intDiff){
  19.                 window.setInterval(function(){
  20.                 var day=0,
  21.                         hour=0,
  22.                         minute=0,
  23.                         second=0;//时间默认值               
  24.                 if(intDiff > 0){
  25.                         day = Math.floor(intDiff / (60 * 60 * 24));
  26.                         hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
  27.                         minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
  28.                         second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
  29.                 }
  30.                 if (minute <= 9) minute = '0' + minute;
  31.                 if (second <= 9) second = '0' + second;
  32.                 $('#day_show').html(day+"天");
  33.                 $('#hour_show').html('<s id="小时"></s>'+hour+'小时');
  34.                 $('#minute_show').html('<s></s>'+minute+'分');
  35.                 $('#second_show').html('<s></s>'+second+'秒');
  36.                 intDiff--;
  37.                 }, 1000);
  38.         }
  39.         $(function(){
  40.                 timer(intDiff);
  41.         });       
  42. </script>
  43. </head>
  44. <body>
  45.   <h1>距离下一期还有</h1>
  46.   <div class="time-item">
  47.   <span id="day_show">0天</span>
  48.   <strong id="hour_show">0小时</strong>
  49.   <strong id="minute_show">0分</strong>
  50.   <strong id="second_show">0秒</strong>
  51.   </div><!--倒计时模块-->
  52. </body>
  53. </html>
复制代码



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|站长网 网站备案:鄂ICP备13006300号-4

GMT+8, 2024-5-3 14:24 , Processed in 0.051150 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表