jquery——动画
1.通过animate方法可以设置元素某属性值上的动画
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>动画</title>
<script type="text/javascript" src="jquery-1.12.4.min.js"></script>
<style type="text/css">
.box{
width:100px;
height:100px;
background-color: hotpink;
}
</style>
<script type="text/javascript">
$(function () {
//参数:
// 1.属性设置{pra1:1,pra2:2}
// 2.speed 时间 ms
// 3.swing(默认值) 开始和结束慢速,中间快速 linear 匀速
// 4.回调函数:动画结束后要做的事情
$('#div1').animate({width:200,height:200},1000,'linear',function () {
$(this).animate({marginLeft:500},1000);
});
})
</script>
</head>
<body>
<div id='div1' class="box"></div>
</body>
</html>
回调函数很强大哦,可以做很多事~
2.each 相当于for循环,这个each()中的第一个参数是索引值
$(function () { $('.list li').each(function (index) { }); })

浙公网安备 33010602011771号