<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href = "login.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
var swidth = $(window).width();
var sheight = $(window).height();
$(document).ready(function(){
$("#box").animate({
top: (sheight*0.22)+"px",
left: (swidth*0.25)+"px",
width:(swidth*0.3)-40+"px",
height: (sheight*0.35)-40+"px",
}, 2000, function(){
$('<input type="button" value="My button">').appendTo(this)
.button().click(function(){
alert('I was clicked!');
});
});
});
</script>
</head>
<body>
<header>
</header>
<section>
<div id="box">
</div>
</section>
</body>
</html>
我希望如此,因为我在 '.animate. 它会等到动画完成。但没有运气。
问题是动画开始时 div 非常小,因此按钮几乎无法放入 div 中,这看起来很糟糕。所以我只希望按钮在动画完成并且 div 处于全尺寸后出现。
感谢您提前提供任何答案。