js 定时器
2021-03-13 05:36
标签:interval NPU onclick gets 自动 div art text gettime js 定时器 标签:interval NPU onclick gets 自动 div art text gettime 原文地址:https://www.cnblogs.com/TKOPython/p/12820785.html
function beging() {
var date = new Date();
var hour = date.getHours();
var fen = date.getMinutes();
var miao = date.getSeconds();
var gettime = [hour,"时",fen,"分",miao,"秒"].join("");
var doc_text = document.getElementById("textview");
doc_text.value = gettime ;
}
//给定时器添加每秒自动获取时间
var ID ;
function start_button() {
if(ID===undefined){
beging();
ID = setInterval(beging,1000)
}
}
//结束时间
function end_button() {
clearInterval(ID);
ID = undefined;
}