jQuery的动画
2016-05-25 09:38
435 查看
jQuery提供了一些动画效果,非常实用,用示例程序简单总结一些。
第二个参数,默认为false,即2秒之后停止在当前动画。如果为true,则在两秒之后,直接变到animate方法执行完的结果,即加100%,大家可以把代码复制运行一下看一下效果。
<html> <head> <title> new document </title> <meta charset="utf-8" /> <script src="jquery/jquery-2.2.4.min.js"> </script> <style type="text/css"> #div01{ background-color: yellow; width: 100px; height: 100px; } </style> </head> <body> <div id="div01">hello world</div></br> <button id="button01">消失和隐藏</button></br> <button id="button02">滑动</button></br> <button id="button03">渐变透明消失</button></br> <button id="button04">改变透明度</button></br> <button id="button05">切换</button></br> <button id="button06">自定义动画</button></br> <button id="button07">停止一切动画</button></br> </body> <script type="text/javascript"> $(document).ready(function(){ //消失和隐藏 $('#button01').on('click',function(){ $('#div01').hide(2000,function(){ $('#div01').show('normal'); }); }); //滑动 $('#button02').on('click',function(){ $('#div01').slideUp(2000,function(){ $('#div01').slideDown('slow'); }); }); //透明度变化 $('#button03').on('click',function(){ $('#div01').fadeOut(2000,function(){ $('#div01').fadeIn('normal'); }); }); //改变透明度至 $('#button04').on('click',function(){ $('#div01').fadeTo('fast', 0.3); }); //切换 $('#button05').on('click',function(){ $('#div01').toggle(); }); //自定义动画 $('#button06').on('click',function(){ $('#div01').animate({ width:"+=100%", height: "+=100%", fontSize: "10em", borderWidth:10 }, 1000); }); //stop的作用 $('#button07').on('click',function(){ $('#div01').animate({ width:"+=100%", height: "+=100%", fontSize: "10em", borderWidth:10 }, 10000).hide(); setTimeout(function(){ $('#div01').stop(); },2000); }); }); </script> </html>最后一个stop方法,里边还有两个参数,stop(true,true);第一个参数如果为true,那么停止自定义动画的后就不会再执行的后边的那个hide()方法。反之则继续执行。
第二个参数,默认为false,即2秒之后停止在当前动画。如果为true,则在两秒之后,直接变到animate方法执行完的结果,即加100%,大家可以把代码复制运行一下看一下效果。
相关文章推荐
- js框架jquery瀑布流图片墙效果代码下载,点击相册图片展示大图
- jquery刷新部分界面
- 关于jQuery和AJAX的详解(二)
- jQuery获取访问者IP地址的方法(基于新浪API与QQ查询接口)
- 《锋利的jQuery》笔记—DOM部分
- 《锋利的jQuery》笔记-jQuery部分
- JQuery的常用选择器、过滤器、方法全面介绍
- jquery属性
- jQuery学习和知识点总结归纳
- jquery 之for 循环
- jquery的遍历用法
- jQuery高级技巧——性能优化篇
- jquery处理后台返回来的JSON,JSON中属性为JSON,或者数组的处理
- jQuery easyUI
- 前端开发者都应知道的 jQuery 小技巧
- 利用 jquery flot pie 生成饼图
- 时间选择器,结合jquery使用
- jQuery中的trigger
- jQuery高级技巧——DOM操作篇
- jQuery分析(3) - jQuery.fn.init