jQuery实现基本动画效果的方法

jQuery实现基本动画效果的方法详解

Html:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
</head>
<style>
body{
padding: 0;
margin: 0;
}
.box{
display: block;
position: fixed;
width: 200px;
height: 200px;
background: #ccc;
}
button{
margin-top: 250px;
}
</style>
<body>
<div class="box">

</div>
<button>开始</button>
</body>
<script>
$(function(){
$(document).on("click","button",function(){
$(".box").removeAttr("style");
$(".box").animate({
"right":"0",
"bottom":"50px"
},1000);

$(".box").animate({
"top":"0px"
},1000);

$(".box").animate({
"left":"0px"
},1000);

setTimeout(function() {
$(".box").removeAttr("style");
}, 3100)
})
})
</script>
</html>

 

注意:记得引入jQuery.js文件

posted @ 2020-05-27 09:33  老和尚106  阅读(266)  评论(0编辑  收藏  举报