如何让span继续运动?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>调用stop()方法停止当前所有动画效果</title>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h3>调用stop()方法停止当前所有动画效果</h3>
<span></span>
<input id="btnStop" type="button" value="停止" />
<input id="btnStop1" type="button" value="继续" />
<div id="tip"></div>
<script type="text/javascript">
$(function () {
$("span").animate({
left: "+=100px"
}, 3000, function () {
$(this).animate({
height: '+=60px',
width: '+=60px'
}, 3000, function () {
$("#tip").html("执行完成!");
});
});
$("#btnStop").bind("click", function () {
$("span").stop();
$("#tip").html("执行停止!");
$("#btnStop1").css("display","block");
});
$("#btnStop1").bind("click",function(){
$("span").animate({left:"+=100px"},3000,function(){
$(this).animate({height:'+=60px',width:'+=60px'},3000,function(){
$("#tip").html("执行完成!");
});
});
});
});
</script>
</body>
</html>
css:
div
{
margin: 10px 0px;
}
span
{
position:absolute;
width:80px;
height:80px;
border: solid 1px #ccc;
margin: 0px 8px;
background-color: Red;
color:White;
vertical-align:middle
}
#btnStop1{
display:none;
}1.按照之前大家说的,又做了一个继续按钮。但是当多次点击继续后,效果会累加。怎么才能让其按照一开始的参数继续执行呢。也就是宽和高变成130就停止?还有位移也是一样。
2.在span没有执行动画前,它在文档里的位置是什么?left:?px;right:?px;top:?px;bottom:?px.