<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
</style>
</head>
<body>
<button id="stop">停止</button>
</body>
</html>
<script>
function a(){
console.log('ok')
}
var taskId = setInterval(a,1000);
var taskId2 = setInterval(function(){
console.log('ok2')
},1000);
var stop = document.getElementById('stop');
stop.onclick = function(){
//停止定时器的进程
clearInterval(taskId)
clearInterval(taskId2)
}
</script>
04-20
584
04-11
449