停止setInterval的clearInterval函数
<!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函数相关推荐
- setInterval 与 clearInterval详解
首先注意,setInterval与clearInterval都是直属于window对象的. 1.直接调用setInterval(即不通过函数调用) <div id="oDiv_show ...
- 789-792---BOM(定时器(setInterval() 定时器),案例 :倒计时,停止setInterval() 定时器,案例:发送短信,this的指向)
文章目录 BOM 3 定时器 3.4 setInterval() 定时器 案例:倒计时 3.5 停止setInterval() 定时器 案例:发送短信 3.6 this BOM 3 定时器 3.4 s ...
- BOM:window对象的方法之setInterval()定时器和停止setInterval()定时器
window.setInterval(回调函数,[间隔的毫秒数]); setInterval()方法是重复调用一个函数,每间隔一段时间就调用一次这个函数. // 每隔两秒就会执行一次这个函数 setI ...
- setInterval和clearInterval
最近在做项目的时候遇到了setInterval和clearInterval这两个js函数,今天特地来感悟记录下 我是在vue的项目中进行的代码,有下面两种用法 第一种:直接在setInterval中使 ...
- 怎么停止html自动刷新桌面,怎么停止setinterval
javascript可以单独停止setInterval吗? jquery setinterval怎么停止. 怎么停止setinterval 可以单独停止一个setInterval的,setInterv ...
- setInterval与clearInterval
setInterval与clearInterval setInterval 定义和用法 语法 返回值 实例 setInterval 定义和用法 setInterval()方法可按照指定的周期(以毫秒计 ...
- HTML DOM setInterval和clearInterval方法案例详解
文章来源: 学习通http://www.bdgxy.com/ 普学网http://www.boxinghulanban.cn/ 智学网http://www.jaxp.net/ 在javascript编 ...
- setInterval 和 clearInterval 的用法
setInterval 和 clearInterval 的用法: var times = 10;var timeOut = setInterval(() => {if (times != 0) ...
- php clearinterval,JavaScript定时函数(2)setInterval与clearInterval
setInterval的使用方法 Document 0 var hid = document.getElementById("hid"); var num = 1; functio ...
最新文章
- RzPageControl 关闭按钮
- 2020中国高校毕业生薪资排行出炉!原来有这么多双非院校薪资这么高!
- NR 5G L3无线资源控制层
- java 马士兵 io 代码分析_学习笔记-马士兵java- (IO初步)流
- python自动解析json_Python语言解析JSON详解
- hp打印机驱动android,惠普打印机驱动
- 基于springboot的物流管理系统设计与实现 JAVA MYSQL
- crossApp部署到Eclipse
- 浪潮 服务器数据安全管理系统,浪潮SSC运维安全管控系统
- Word - 修改界面语言和校对语言
- 【CodeForces 1253B --- Silly Mistake】
- 什么时候使用PHP设计模式和为什么要使用?
- Codeforces Global Round 16 D2. Seating Arrangements (hard version)
- 广西工业职业技术学院计算机宿舍,广西工业职业技术学院2021年宿舍条件
- 编译原理 赋值语句翻译成四元式
- 招聘·全球物流信息查询SaaS服务公司
- 零基础可以学习厚涂么?
- 使用python自动签到CSDN
- 港口码头应急广播系统解决方案
- 表格识别论文阅读——《Robust Table Detection and Structure Recognition from Heterogeneous Document Images》