码迷,mamicode.com
首页 > 其他好文 > 详细

设计图片反复闪,点击后停止(设计定时器)

时间:2017-01-04 00:05:23      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:button   lang   height   doc   position   rip   停止   put   ack   

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
</head>
<style>
div{
width: 200px;
height: 200px;
background-color: blue;
position: absolute;
left: 60px;
visibility: visible;
}
</style>
<body>
<input type="button" value="按钮" id="btn"/>
<div id="demo"></div>
</body>
<script>

//定时器函数show

function show(){
var demo=document.getElementById(‘demo‘);
if(demo.style.visibility == "visible"){
demo.style.visibility ="hidden";
}else{
demo.style.visibility=‘visible‘;
}
var timer=setTimeout(‘show()‘,300);
var btn=document.getElementById(‘btn‘);
btn.onclick=function(){//点击取消定时器
clearInterval(timer);
}
}
show();//调用定时器
</script>
</html>

设计图片反复闪,点击后停止(设计定时器)

标签:button   lang   height   doc   position   rip   停止   put   ack   

原文地址:http://www.cnblogs.com/mcpark/p/6246916.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!