<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>一道JS面试题</title>
<style>
body
{
 font-size
:12px;
 font-family
:"微软雅黑";
 line-height
:1.8;
}
</style>
</head>

<body>
<h3>一道JS大面试题</h3>
<p>题目在网页里倒计时显示当年剩下的天时分秒,格式:XX年还剩下X天X时X分X秒</p>
<div id="m1"></div>
<script type="text/javascript">
(
function(){
 
var day=hour=minitus=second=ms=0;
 
var year=new Date().getFullYear()+1;
 
var tmp=new Date(year,0,1)-new Date();
 day
=Math.floor(tmp/86400000);
 (function(){
  tmp
=(new Date(year,0,1)-new Date())%86400000;
  hour
=Math.floor(tmp/3600000);
  tmp%=3600000;
  minitus
=Math.floor(tmp/60000);
  tmp%=60000;
  second
=Math.floor(tmp/1000);
  ms=tmp-1000*second;
  
  document.getElementById(
"m1").innerHTML="距离"+year+"年还有 "+day+" 天 "+hour+" 小时 "+minitus+" 分 "+second+" 秒 "+ms;
  setTimeout(arguments.callee,
50);
 })();
})();
</script>
</body>
</html>

相关文章:

  • 2022-02-09
  • 2022-12-23
  • 2021-06-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-23
  • 2022-12-23
  • 2022-02-20
  • 2022-12-23
  • 2021-08-20
  • 2021-07-15
相关资源
相似解决方案