<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<input type="text" id="ip">
<button id="btn1">开始</button>
<button id="btn2">结束</button>
<script>
var t;
function showTime() {
var ip = document.getElementById('ip');
var time = new Date();
ip.value = time.toLocaleString();
}
showTime();
var btn1 = document.getElementById('btn1');
btn1.onclick = function (e) {
if (!t){
t = setInterval(showTime,1000)
};
};
var btn2 = document.getElementById('btn2');
btn2.onclick = function (e) {
clearInterval(t);
t = undefined;
};
</script>
</body>
</html>
DOM之定时器计时效果
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:DOM之选项卡
下一篇:DOM之select联动效果
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
uniapp 之倒计时兼定时器代码及效果
uniapp 倒计时兼定时器
2d 当前页 javascript -
模拟播放器倒计时效果
值得好好参谋。
ide ico css html jquery -
js日期倒计时效果
倒计时 还剩
html css xml -
suface BIOS 设置硬件虚拟化
最近,很多有关微软Windows 10X的消息被爆出。尤其是相比现版Win10更新颖的UI设计,吸引了众多目光。好消息是,微软已于近期开放了Win10X模拟器的下载,让我们可以提早对这款操作系统一探究竟。接下来,小编就教你如何一步步完成Win10X模拟器的安装。 首先需要说明的是,这是模拟器!并非实机操作系统,而且对电脑的软硬件要求是比较高的,如果你的电脑不符合要求,目前不建议体验。Win10X
suface BIOS 设置硬件虚拟化 win10亮度 win10玩cf不能全屏 win10玩cf如何调全屏 win10语言栏不见了