当前位置:网站首页>Timer case
Timer case
2022-06-26 02:09:00 【Asmruan】
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
header {
height: 500px;
width: 400px;
background-color: cyan;
margin: auto;
text-align: center;
padding-top: 40px;
}
button {
margin: 10px;
}
</style>
</head>
<body>
<header>
<div>
<span>00 </span>
<span>00 </span>
<span>00 </span>
</div>
<div><button> Start </button></div>
<div><button> Pause </button></div>
<div><button> Zeroing </button></div>
</header>
</body>
</html>
<script>
function add0(num) {
return num >= 10 ? num : "0" + num;
}
var start = document.querySelectorAll("button")[0];
var pause = document.querySelectorAll("button")[1];
var stop = document.querySelectorAll("button")[2];
var h = document.querySelectorAll("span")[0];
var m = document.querySelectorAll("span")[1];
var s = document.querySelectorAll("span")[2];
var num = 0;
var timer = null;
start.addEventListener("click", function () {
timer = setInterval(function () {
num++;
s.innerHTML = add0(num);
// Hours rounded down
var hour = add0(Math.floor(num / 60 / 60));
// 66 1 Zero 6 second
// 1 Hours = 60*60 = 3600s
// 3666 1 Hours 1 branch 6 second
// 62
var minutes = add0(Math.floor(num / 60) % 60);
var second = add0(num % 60);
h.innerHTML = hour;
m.innerHTML = minutes;
s.innerHTML = second;
}, 0);
});
</script>
边栏推荐
猜你喜欢

Shell learning record (II)

Abnova anti GBA monoclonal antibody solution

Interface test case design

Eureka注册信息配置备忘

Implementation of image binary morphological filtering based on FPGA -- Corrosion swelling

Chrome browser developer tool usage
![[untitled] vsbiji ESP thirty-two](/img/08/c479031c80d4dfdd8a05d530ae30ba.png)
[untitled] vsbiji ESP thirty-two

Pointnet/pointnet++ learning

樹莓派 + AWS IoT Greengrass

SDRAM controller -- implementation of arbitration module
随机推荐
Prometeus 2.33.0 新特性
Implementation of image binary morphological filtering based on FPGA -- Corrosion swelling
Two indicators for determining the value of points to the business
Exploring temporary information for dynamic network embedding
CVPR2022 | 长期行动预期的Future Transformer
weishi相机显示
UN make (6) conditional execution of makefile
Chrome browser developer tool usage
Chinese and English instructions of collagen enzyme Worthington
How to efficiently complete daily tasks?
Chrome浏览器开发者工具使用
SDRAM Controller - add read / write FIFO
购买了fastadmin小程序助手但是问题工单中无法发布工单
Easy to understand C language keyword static
Disruptor(一)Sequence
如何制定一个可实现的年度目标?
Cross server SQL connection configuration
vs2015+PCL1.8.1+qt5.12-----(1)
Pointnet/Pointnet++学习
Redis-链表