我想在屏幕滚动的时候把_time
设为零,就是立马让div
为hide()
,而不是关闭定时器
这样能做吗?
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
</head>
<body>
<input type="button" value="点击" class="show"/>
<div class="dis">hello</div>
<script>
$(function(){
var _time = 3000;
$('.show').click(function(){
timer3 = setTimeout(function(){
$(".dis").hide();
},_time);
})
window.scroll(function(){
})
})
</script>
</body>
</html>
直接在屏幕滚动的时候,将
div
hide()
不就行了吗,一定要用定时器兜个圈子吗?