本篇文章介绍的内容是关于用js做时钟的代码,现在分享给大家,有需要的朋友可以参考一下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" type="text/css" href="系统CSS初始化.css">
<style> ul{ height: 100px; width: 600px; margin: 200px auto;
} img{ float:left;
} span{ font-size: 100px; float: left; display: block; position: relative; bottom: 20px;
}
</style>
<script> window.onload=function ()
{ function setDoub(n) { if(n<10)
{
n='0'+n;
} else {
n=''+n;
} return n;
} var aImg=document.getElementsByTagName("img"); function tick() { var date=new Date(); var str=setDoub(date.getHours())+setDoub(date.getMinutes())+setDoub(date.getSeconds()); for(var i=0;i<aImg.length;i++)
{ aImg[i].src="images/"+str[i]+".png";
}
} tick(); setInterval(tick,1000)
}
</script>
</head>
<body>
<ul id="ul1">
<img src="images/0.png">
<img src="images/0.png">
<span>:</span>
<img src="images/0.png">
<img src="images/0.png">
<span>:</span>
<img src="images/0.png">
<img src="images/0.png">
</ul>
</body>
</html>以上就是用JS做时钟的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号