JQuery自定义动画效果

Original 2018-11-08 11:53:44 195
abstract:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> body{font-size:12px;}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
body{font-size:12px;}
div{width:100px;height:100px;background:red;position:absolute;}
</style>
<script type="text/javascript" src="js/jquery-3.3.1.js"></script>
</head>
<body>
<button id="bt1">开始动画</button>
<div>我也会动</div>


<script type="text/javascript">
$(document).ready(function(){
$('#bt1').click(function(){
$('.div1').animate({height:'500px'},'slow')
$('.div1').animate({width:'500px'},'slow')
$('.div1').animate({fontSize:'100px',fontWeight:'bold'})
$('.div1').animate({height:'100px'},'fast')
$('.div1').animate({width:'100px'},'fast')
$('.div1').animate({fontSize:'12px',fontWeight:'normal'})
})
})
</script>
</body>
</html>

方法类似于CSS,但是更加简单化。

通过事件触发动画,动画通过队列一个个展示,变成最后的效果

Release Notes

Popular Entries