js 고전 사례 의 카운트다운
3713 단어 입문 에서 전복 까지 전단 학습
<html lang="en">
<head>
<meta charset="UTF-8">
<title> title>
head>
<body>
<p> 2020 <span>span>!p>
<script>
var span=document.getElementsByTagName("span")[0];
var holiday = new Date('2020/10/1');
var day;//
var hour;//
var min;//
var sec;//
// ,
setInterval(function () {
var now = new Date();
var long = holiday.getTime()-now.getTime();//
sec=parseInt(long/1000%60);
min=parseInt(long/1000%3600/60);// 60
hour=parseInt(long/1000%(3600*24)/3600);// , 3600
day=parseInt(long/1000/60/60/24);
span.innerHTML=day+" "+hour+" "+min+" "+sec+" ";
},1000)
script>
body>
html>