为什么点击按钮 jquery的 clearInterval()不起作用
<!doctypehtml><html><head><metacharset="gb2312"><title>jump</title><scriptsrc="http:/...
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>jump</title>
<script src="http://jqueryui.com/jquery-wp-content/themes/jquery/js/jquery-1.11.2.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
</head>
<body style="position:relative">
<div style="height:100px;width:100px; background:#A7B568; position:absolute;top:0px;left:300px" id="jump"></div>
<button style="margin-top:200px" onClick="stopJump()">jump</button>
<script>
var int=setInterval(jumpDiv,50);
function jumpDiv(){
$("#jump").animate({"top":"300px",},1000,'easeInQuad'),
$("#jump").animate({"top":"0px",},1000,'easeOutQuad')
};
function stopJump(){
clearInterval(int);//不起作用
}
</script>
</body>
</html> 展开
<html>
<head>
<meta charset="gb2312">
<title>jump</title>
<script src="http://jqueryui.com/jquery-wp-content/themes/jquery/js/jquery-1.11.2.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
</head>
<body style="position:relative">
<div style="height:100px;width:100px; background:#A7B568; position:absolute;top:0px;left:300px" id="jump"></div>
<button style="margin-top:200px" onClick="stopJump()">jump</button>
<script>
var int=setInterval(jumpDiv,50);
function jumpDiv(){
$("#jump").animate({"top":"300px",},1000,'easeInQuad'),
$("#jump").animate({"top":"0px",},1000,'easeOutQuad')
};
function stopJump(){
clearInterval(int);//不起作用
}
</script>
</body>
</html> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询