Blogger Information
Blog 2
fans 0
comment 0
visits 1516
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
jQuery倒计时小案例
木子曈的博客
Original
660 people have browsed it
<!DOCTYPE html>
<html>
<head>	
	<title>五一倒计时</title>
	<meta charset="utf-8">
	<link rel="icon" type="image/x-icon" href="static/images/favicon.ico">
	<script type="text/javascript" src="static/jquery-3.3.1.min.js"></script>
	<style type="text/css">
	  
	  *{margin: 0;padding: 0;}
	  div{
	  	font-size: 36px;
	  	width: 1300px;
	  	height: 180px;
	  	margin: 100px auto;
	  	background: #82d743;
	  	line-height: 180px;
	  	text-align: center;
	  	color:#fff;
	  }		
	</style>

</head>
<body>
	<div>
		<p>2019年五一倒计时:<span></span></p>
	</div>


	<script type="text/javascript">
       $(function(){
       	    function Ro(){
          // parse()方法可解析一个日期时间字符串,并返回1970/1/1 午夜距离该日期时间的毫秒数。
          var d=Date.parse("May 01,2019") // 返回 1970/1/1 午夜距离该日期时间的毫秒数
          var date=new Date(); //获取当前时间
          var dd=date.getTime() //getTime() 方法可返回距 1970 年 1 月 1 日之间的毫秒数
          // 1秒等于1000毫秒,1分钟等于60秒,一小时=60分钟等于3600秒,一天24小时=86400秒
          var rd=Math.floor((d-dd)/1000);//得到总的秒数
          var days=Math.floor(rd/86400);//得到总的天数
          var hours=Math.floor(rd%86400/3600);//得到小时
          var minus=Math.floor(rd%3600/60);//得到分钟
          var secos=Math.floor(rd%60); //得到秒数
          $('span').text(days+"天"+hours+"小时"+minus+"分钟"+secos+"秒")

        }
        setInterval(Ro,1000)


       })		
 




	</script>
	

</body>
	

</html>


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post