javascript倒计时

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>js倒计时</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
</head>
<body>
    <div id="remainTimer">距离2016年还有:<b></b>天<b></b>小时<b></b>分钟<b></b>秒</div>
    <script src="http://cdn.bootcss.com/jquery/2.1.0/jquery.js"></script>
    <script>
   function predate(yy,mm,dd,hh,mi,second){
    var currentdate=new Date().getTime();
     var yy=yy||0,mm=mm||0,dd=dd||0,hh=hh||0,mi=mi||0,second=second||0;
     var futuredate=new Date(yy,mm-1,dd,hh,mi,second).getTime();
     var cha=futuredate-currentdate;
    var remainDay=parseInt(cha/1000/60/60/24,10); //计算天数取整数
    var remainHour=parseInt(cha/1000/60/60%24,10);//除去天数,剩余的整数就是小时
    var remainMinute=parseInt(cha/1000/60%60,10);//除去小时,剩余的整数就是分钟
    var remainSecond=parseInt(cha/1000%60,10);     //除去分钟,剩余的整数就是秒
     $("#remainTimer b").first().text(remainDay).end().eq(1).text(remainHour).end().eq(2).text(remainMinute).end().last().text(remainSecond);
    };
    function showtime(){
     var showcontent=predate(2016,1,1);
      setTimeout('showtime()',1000);
    }
   showtime();
    </script>
</body>
</html>


你可能感兴趣的:(js,jquery)