<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>jq动画效果</title> <script src="jquery-3.3.1.min.js"></script> <style> div{width: 200px;height: 200px;background: blue;position: absolute;} </style> <script> // $(选择器).animate({params},speed,fn) --> 添加定位属性div可移动 // 预定义的值 宽高:'toggle' 隐藏显示 // stop()停止动画或效果,$('选择器').stop(stopAll,goToEnd) $(document).ready(function(){ $('.but1').click(function(){ $('p').animate({fontSize:'40px'},1500) }) $('.but2').click(function(){ $('div').animate({ left:'400px', opacity:'0.4',//颜色变化 height :'400px',width:'400px' // height:'toggle' },3500) //字体变大 $('div').animate({fontSize :'30px'},500) }) $('.but3').click(function(){ $('div').stop() }) }) </script> </head> <body> <button>点击字体放大</button> <p>东湖效果的规范的</p> <button>点击div移动</button> <button>点击停止移动</button> <div>字体哦哦哦哦哦哦</div> </body> </html>
在上一个案例基础上加了停止效果,语法,$('选择器').stop('参数')