【JS】setInterval函数
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>d24c04429</title>
</head>
<body>
<p>点击按钮,等待3秒可以弹出hello!点击弹出框的确定后,三秒后将会循环。</p>
<button onclick="myFunction()">点击我</button>
<script>
var myVar;
function myFunction() {
myVar = setInterval(alertFunc, 3000);
}
function alertFunc(){
alert("Hello!");
}
</script>
</body>
</html>