<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<style>
.box{
width: 100px;
height: 100px;
background: pink;
position: absolute;
top:0;
left: 0;
}
</style>
<body>
<div class="box">
</div>
<script src="jquery-3.3.1.js"></script>
<script>
$('.box').click(function () {
$('.box').animate({'top':500,'left':500}).delay(100).//delay延迟
animate({'top':470,'left':470},100).animate({'top':500,'left':500},100).
animate({'top':480,'left':480},100).animate({'top':500,'left':500},100).
animate({'top':490,'left':490},100).animate({'top':500,'left':500},100).
animate({'queue':true},function () {
$(this).css({'transition': 'all 1s','transform':'rotate(180deg)'});
}).queue(function (next) {
$(this).css({'background': '#f60'});
next()//有一个参数保存函数,调用可以让动画接着执行
}).animate({'opacity':0.3})
})
</script>
</body>
</html>
(记录)jquery中使用动画的一个小例子
猜你喜欢
转载自blog.csdn.net/qq_44361433/article/details/90685389
今日推荐
周排行