<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>countDown</title> <meta name="description" content=""> <meta name="keywords" content=""> <link href="" rel="stylesheet"> </head> <body> <span></span> <span>天</span> <span></span> <span>小时</span> <span></span> <span>分钟</span> <span></span> <span>秒</span> <span></span> <span>毫秒</span> </body> <script type="text/javascript"> var spans = document.getElementsByTagName('span'); var endDate = new Date('2015/06/01,00:00:00'); var timer = setInterval(function(){ var nowDate = new Date(); var a = endDate.getTime()-nowDate.getTime(); spans[0].innerHTML = Math.floor(a/24/60/60/1000); spans[2].innerHTML = Math.floor(a/60/60/1000%24); spans[4].innerHTML = Math.floor(a/60/1000%60); spans[6].innerHTML = Math.floor(a/1000%60); spans[8].innerHTML = Math.floor(a%1000); },1) </script> </html>