42 lines
1.3 KiB
HTML
42 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
|
|
|
|
<title>白桃粉可爱风的立体字时钟</title>
|
|
<link rel="stylesheet" href="../css/72.css">
|
|
<script type="text/javascript">
|
|
function myTime(){
|
|
let time=new Date();
|
|
let hh=time.getHours(); //时
|
|
let mm=time.getMinutes(); //分
|
|
let ss=time.getSeconds(); //秒
|
|
// Math.floor() 向下取整
|
|
document.getElementById("1").innerText=Math.floor(hh/10);
|
|
document.getElementById("2").innerText=hh%10;
|
|
document.getElementById("4").innerText=Math.floor(mm/10);
|
|
document.getElementById("5").innerText=mm%10;
|
|
document.getElementById("7").innerText=Math.floor(ss/10);
|
|
document.getElementById("8").innerText=ss%10;
|
|
}
|
|
// 一秒执行一次
|
|
setInterval(myTime,1000);
|
|
</script>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="clock">
|
|
<p id="1">0</p>
|
|
<p id="2">0</p>
|
|
<p id="3">:</p>
|
|
<p id="4">0</p>
|
|
<p id="5">0</p>
|
|
<p id="6">:</p>
|
|
<p id="7">0</p>
|
|
<p id="8">0</p>
|
|
</div>
|
|
</body>
|
|
|
|
</html> |