Home > Web Front-end > JS Tutorial > Js complete countdown time difference effect

Js complete countdown time difference effect

Y2J
Release: 2017-05-20 13:17:13
Original
1503 people have browsed it

This article mainly introduces Javascript to implement the countdown time difference effect in detail. It has certain reference value. Interested friends can refer to it.

The example in this article shares with you the js countdown time difference effect. The implementation code is for your reference. The specific content is as follows

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>当前系统时间</title>
<link rel="stylesheet" href="style.css" />
<script language="javascript" type="text/javascript">

 window.onload = function(){
 showTime();
 }
 function checkTime(i){ //补位处理
 if(i<10){
  i=&#39;0&#39;+i;
 }
 return i;
 }
 function showTime(){
 var now=new Date();
 var year= now.getFullYear();
 var month= now.getMonth()+1;
 var day= now.getDate();
 var h= now.getHours();
 var m= now.getMinutes();
 var s= now.getSeconds();
 m=checkTime(m);
 s=checkTime(s);

 var weekday=new Array(7)
 weekday[0]="星期日"
 weekday[1]="星期一"
 weekday[2]="星期二"
 weekday[3]="星期三"
 weekday[4]="星期四"
 weekday[5]="星期五"
 weekday[6]="星期六"

 document.getElementById("show").innerHTML=""+year+"年"+month+"月"+day+"日 "+ ? +h+":"+m+":"+s;
 t=setTimeout(&#39;showTime()&#39;,500)
 }

</script>
</head>
<body>
<p class="content1">
 <p id="show">显示时间的位置</p>
</p>
</body>
</html>
Copy after login

[Related recommendations]

1. Javascript free video tutorial

##2.

Detailed explanation of the method of recursively deleting elements in an array in JS

3.

Detailed explanation of an example of JS completing the star rating function

4.

How does JS determine whether text is full-width or half-width?

5.

nodejs+websocket completes a chat system function

The above is the detailed content of Js complete countdown time difference effect. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template