<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="button" value="开始" id="btn1">
<input type="button" value="取消" id="btn2">
<script>
var btn1 = document.getElementById('btn1');
var btn2 = document.getElementById('btn2');
var timer;
btn1.onclick = function () {
timer = setInterval(function () {
console.log('早上7点了');
}, 3000);
}
btn2.onclick = function () {
clearInterval(timer);
}
</script>
</body>
</html>