<!DOCTYPE html>
<html><head><meta charset="utf-8"><title>setInterval使用方法</title><style type="text/css">.com {width: 200px;height: 30px;background-color: burlywood;/* color: orange; */line-height: 30px;font-family: serif;text-align: center;}.hand {display: inline-block;background: #333;border-radius: 4px;width: 28px;height: 28px;margin: 0 5px;font-size: 18px;color: #fff;vertical-align: middle;text-align: center;line-height: 28px;}</style></head><body><script type="text/javascript">window.addEventListener('load', function() {var stop = document.querySelector('.stop');var b = document.querySelector('.begin');//                b.addBehavior('click')var timer = null;b.addEventListener('click', function() {timer = setInterval(function() {console.log('开始计时');}, 1000)})stop.addEventListener('click',function(){clearInterval(timer);})})</script><button class="stop">停止</button><button class="begin">开始</button></body></html>

停止setInterval的clearInterval函数相关推荐

  1. setInterval 与 clearInterval详解

    首先注意,setInterval与clearInterval都是直属于window对象的. 1.直接调用setInterval(即不通过函数调用) <div id="oDiv_show ...

  2. 789-792---BOM(定时器(setInterval() 定时器),案例 :倒计时,停止setInterval() 定时器,案例:发送短信,this的指向)

    文章目录 BOM 3 定时器 3.4 setInterval() 定时器 案例:倒计时 3.5 停止setInterval() 定时器 案例:发送短信 3.6 this BOM 3 定时器 3.4 s ...

  3. BOM:window对象的方法之setInterval()定时器和停止setInterval()定时器

    window.setInterval(回调函数,[间隔的毫秒数]); setInterval()方法是重复调用一个函数,每间隔一段时间就调用一次这个函数. // 每隔两秒就会执行一次这个函数 setI ...

  4. setInterval和clearInterval

    最近在做项目的时候遇到了setInterval和clearInterval这两个js函数,今天特地来感悟记录下 我是在vue的项目中进行的代码,有下面两种用法 第一种:直接在setInterval中使 ...

  5. 怎么停止html自动刷新桌面,怎么停止setinterval

    javascript可以单独停止setInterval吗? jquery setinterval怎么停止. 怎么停止setinterval 可以单独停止一个setInterval的,setInterv ...

  6. setInterval与clearInterval

    setInterval与clearInterval setInterval 定义和用法 语法 返回值 实例 setInterval 定义和用法 setInterval()方法可按照指定的周期(以毫秒计 ...

  7. HTML DOM setInterval和clearInterval方法案例详解

    文章来源: 学习通http://www.bdgxy.com/ 普学网http://www.boxinghulanban.cn/ 智学网http://www.jaxp.net/ 在javascript编 ...

  8. setInterval 和 clearInterval 的用法

    setInterval 和 clearInterval 的用法: var times = 10;var timeOut = setInterval(() => {if (times != 0) ...

  9. php clearinterval,JavaScript定时函数(2)setInterval与clearInterval

    setInterval的使用方法 Document 0 var hid = document.getElementById("hid"); var num = 1; functio ...

最新文章

  1. RzPageControl 关闭按钮
  2. 2020中国高校毕业生薪资排行出炉!原来有这么多双非院校薪资这么高!
  3. NR 5G L3无线资源控制层
  4. java 马士兵 io 代码分析_学习笔记-马士兵java- (IO初步)流
  5. python自动解析json_Python语言解析JSON详解
  6. hp打印机驱动android,惠普打印机驱动
  7. 基于springboot的物流管理系统设计与实现 JAVA MYSQL
  8. crossApp部署到Eclipse
  9. 浪潮 服务器数据安全管理系统,浪潮SSC运维安全管控系统
  10. Word - 修改界面语言和校对语言
  11. 【CodeForces 1253B --- Silly Mistake】
  12. 什么时候使用PHP设计模式和为什么要使用?
  13. Codeforces Global Round 16 D2. Seating Arrangements (hard version)
  14. 广西工业职业技术学院计算机宿舍,广西工业职业技术学院2021年宿舍条件
  15. 编译原理 赋值语句翻译成四元式
  16. 招聘·全球物流信息查询SaaS服务公司
  17. 零基础可以学习厚涂么?
  18. 使用python自动签到CSDN
  19. 港口码头应急广播系统解决方案
  20. 表格识别论文阅读——《Robust Table Detection and Structure Recognition from Heterogeneous Document Images》

热门文章

  1. 程序员碰到过哪些瞠目结舌的bug呢? 伪装 | 的汉字丨你是真的6!
  2. 百度前端实战训练营第四弹
  3. Windows CE 6.0 vs 7.0
  4. 《原生爬虫》爬取某直播平台某分类下的主播人气,生成排行榜
  5. 酒店入住时间和离店时间的日期选择
  6. 什么是端口,怎样查看端口,关闭/开启端口,各种端口的作用
  7. Http | 工作机制
  8. 浪涌(Surge)抗扰度标准解读
  9. MySQL之MGR原理+保姆级配置部署
  10. #车载电子工具——CANalyzer 与 CANoe软件功能对比