时钟代码(时间显示代码_时钟编程代码)

发布时间:2025-12-10 19:43:38 浏览次数:3

时间显示代码_时钟编程代码-

时间显示代码_时钟编程代码1<!DOCTYPEhtml><htmllang=”en”><head><metacharset=”UTF-8″><metahttp-equiv=”X-UA-Compatible”content=”IE=edge”><metaname=”viewport”content=”width=device-width,initial-scale=1.0″><title…

1<!DOCTYPEhtml>

<htmllang=”en”>

<head>

<metacharset=”UTF-8″>

<metahttp-equiv=”X-UA-Compatible”content=”IE=edge”>

<metaname=”viewport”content=”width=device-width, initial-scale=1.0″>

<title>Document</title>

</head>

<body>

<inputtype=”text”>

<buttonid=”start”>开始计数</button>

<buttonid=”stop”>停止计数</button>

<script>

// 获取开始计数按钮

var start = document.getElementById(“start”);

var num = 0;

var timer ;

start.onclick = function(){

timer = setInterval(function(){

num++;

console.log(num);

document.querySelector(“input”).value = num;

}, 1000);

}

document.getElementById(“stop”).onclick = function(){

// 停止定时器

clearInterval(timer);

}

</script>

</body>

</html>

2.这是一个显示时间的代码。

需要做网站?需要网络推广?欢迎咨询客户经理 13272073477