animate自定义动画
animate()用于创建自定义动画。
基本语法
animate(params,[speed],[easing],[fn])
参数说明
params:一组包含作为动画属性和终值的样式属性和及其值的集合
speed:三种预定速度之一的字符串(“slow”,“normal”, or “fast”)或表示动画时长的毫秒数值(如:1000)
easing:要使用的擦除效果的名称(需要插件支持). 默认jQuery提供 “linear” 和 “swing”.
fn:在动画完成时执行的函数,每个元素执行一次。
示例代码
<script src="js/jquery-3.6.0.js"></script>
<style>
#key3{
width: 300px;
height: 300px;
background-color: blue;
position: absolute;
}
</style>
</head>
<body>
<button id="key1">移动</button>
<button id="key2">变小</button>
<div id="key3"></div>
</body>
<script>
$(function(){
$("#key1").click(function(){
$("#key3").an