赞
踩
js的定时器主要是分为三种:单词定时器、循环/多次定时器、删除定时器
具体代码如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script> window.onload=function(){ var one = document.getElementById("one") var much = document.getElementById("much") var clear = document.getElementById("clear") function put(){ alert('这是单次定时器') } one.onclick=function(){ setTimeout(put) } function put_1(){ alert('这是循环多次定时器') } much.onclick=function() { much1=setInterval(put_1, 2500) } clear.onclick=function (){ clearInterval(much1) } } </script> </head> <body> <button id="one">单次定时器</button> <button id="much">循环多次定时器</button> <button id="clear">删除定时器</button> </body> </html>
主要的定时器就是这三个
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。