当前位置:网站首页>JS global timer case
JS global timer case
2022-06-10 12:55:00 【000000001111】
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title> timer </title>
<style>
* {
margin: 0;
padding: 0;
}
#box {
width: 400px;
height: 400px;
margin: 40px auto;
}
#box div {
width: 200px;
height: 40px;
border: 1px #F3C solid;
text-align: center;
float: left;
font-size: 26px;
}
#box button {
float: left;
margin-top: 10px;
margin-left: 20px;
}
#box span {
float: left;
width: 200px;
height: 100px;
overflow-y: auto;
display: block;
border: 1px #C9C solid;
margin-top: 10px;
}
</style>
</head>
<body>
<div id="box">
<div id="timer"></div>
<button onClick="btTime()"> Start serving </button>
</div>
<script type="text/javascript">
var timer = document.getElementById("timer");
var butt = document.getElementsByTagName("button");
var hour = '00'; // when
var minus = '00'; // branch
var seconds = '00'; // second
timer.innerHTML = hour + ":" + minus + ":" + seconds;
var x = 0,
y = 0,
f = 0,
a = 0,
b = 0,
t1, t2;
var flag = 0;
function btTime() {
/*ajax:*/
switch (flag) {
case 0:
flag = 1;
w = 1;
t1 = setInterval(beginS, 1000);
butt[0].innerHTML = ' End of service ';
break;
case 1:
flag = 2;
clearInterval(t1);
butt[0].innerHTML = ' Service ended ';
break;
}
}
function beginS() {
// Calculate seconds
x++;
if (x < 10) {
seconds = '0' + x;
} else if (x >= 10 && x <= 59) {
seconds = x;
} else if (x > 59) {
seconds = '00';
x = 0;
a++;
}
if (a < 10) {
minus = '0' + a;
} else if (a >= 10 && a <= 59) {
minus = a;
} else if (a > 59) {
minus = '00';
a = 0;
b++;
}
if (b < 10) {
hour = '0' + b;
} else if (b >= 10 && b <= 59) {
hour = b;
}
timer.innerHTML = hour + ":" + minus + ":" + seconds;
}
</script>
</body>
</html>
Please see the original link for details .
Reprint : Thanks for sharing.
Link to the original text :https://wangxiaoting.blog.csdn.net/article/details/82456877?spm=1001.2014.3001.5502

边栏推荐
- Add line number field to SQL query results - sqlserver
- Give root password for maintenace (or press Control-D to continue):解决方法
- Stm32f407 learning notes (1) -exti interrupt event and NVIC register
- Dynaslam ii: carefully coupled multi object tracking and slam
- If the files and graphics are lost, it means that you don't need the office developed by yourself
- Offer has been made, advanced learning
- Get enumeration values through reflection
- Minimalist random music player
- Tidb Primary course experience 8 (Management Maintenance of Clusters, add a tikv Node)
- CC2642R 蓝牙MCU芯片的学习
猜你喜欢

Learning of cc2642r Bluetooth MCU chip

(7) Deep and shallow copy

从解读 BDC 自动生成的代码谈起,讲解 SAPGUI 的程序组成部分试读版

DynaSLAM II: Tightly-Coupled Multi-Object Tracking and SLAM 论文阅读

Tidb Primary course experience 8 (Management Maintenance of Clusters, add a tikv Node)
![VDO-SLAM源码阅读笔记[1] Track()中动态obj部分](/img/18/7260d5b8dba4dcdb64d7f299198ad0.png)
VDO-SLAM源码阅读笔记[1] Track()中动态obj部分

Program, calculate 2/1+3/2+5/3+8/5 Value of. It is required to calculate the sum of the first n items and keep 2 decimal places (starting from the second item of the sequence, the numerator of each it

实战案例,深入剖析

文档提升计划第二期|OceanBase 邀您一起进行文档共建

Learning of fm4057s single lithium battery linear charging chip
随机推荐
【抬杠C#】如何实现接口的base调用
Count the number and average value of natural numbers whose sum of bits within 100 is 7
编写程序,计算2/1+3/2+5/3+8/5.....的值。要求计算前n项之和,保留2位小数(该序列从第二项起,每一项的分子是前一项分子与分母的和,分母是前一项的分子)
Ad-pcb schematic diagram learning (1)
CMakeLists. Txt how to write
Give root password for maintenace (or press Control-D to continue): solution
Element close and destroy the pop-up box: clear the data cache in the pop-up box (organize)
实战案例,深入剖析
20年技术老兵放弃大厂CTO头衔!这家创业公司凭什么吸引他?
软件项目管理 6.10.成本预算
TIDB 初級課程體驗 8 (集群的管理維護, 添加一個TIKV節點)
MySQL service evolution
If the files and graphics are lost, it means that you don't need the office developed by yourself
JS translates Arabic numerals into Chinese capital figures, JS converts figures into capital amounts (sorting)
KITTI 相关信息汇总
UML class diagram
Automatic Mapping of Tailored Landmark Representations for Automated Driving and Map Learning 论文阅读
从解读 BDC 自动生成的代码谈起,讲解 SAPGUI 的程序组成部分试读版
别把“IT信息化”不当“超级工程”
Today, a couple won the largest e-commerce IPO in Hong Kong