JQ 简单动画显示隐藏效果
2017-11-02 22:24
351 查看
一、概括
jq的显示隐藏动画总共有:
普通显示隐藏效果主要用了hide、show、toggle
淡入淡出主要用到了fadeIn、fadeOut、fadeToggle
滑动效果主要用了slideDown、slideUp、slideToggle
其中各效果用到的toggle都是其他两个属性的切换
二、实例
普通显示隐藏效果:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="jquery-2.1.4.min.js"></script> <script> $(document).ready(function() { $("#hide").click(function () { $("p").hide(1000); }); $("#show").click(function () { $("p").show(1000); }); //用于切换被选元素的 hide() 与 show() 方法。 $("#toggle").click(function () { $("p").toggle(); }); }) </script> <link type="text/css" rel="stylesheet" href="style.css"> </head> <body> <p>hello</p> <button id="hide">隐藏</button> <button id="show">显示</button> <button id="toggle">切换</button> </body> </html>
淡入淡出效果:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="jquery-2.1.4.min.js"></script> <script> $(document).ready(function(){ $("#in").click(function(){ $("#id1").fadeIn(1000); }); $("#out").click(function(){ $("#id1").fadeOut(1000); }); $("#toggle").click(function(){ $("#id1").fadeToggle(1000); }); $("#fadeto").click(function(){ $("#id1").fadeTo(1000,0.4); }); }); </script> </head> <body> <button id="in">fadein</button> <button id="out">fadeout</button> <button id="toggle">fadetoggle</button> <button id="fadeto">fadeto</button> <div id="id1" style="display:none; width: 80px;height: 80px;background-color: blueviolet"></div> </body> </html>
滑动效果:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="jquery-2.1.4.min.js"></script> <script> $(document).ready(function(){ $("#slideDown").click(function(){ $("#content").slideDown(1000); }); $("#slideUp").click(function(){ $("#content").slideUp(1000); }); $("#slideToggle").click(function(){ $("#content").slideToggle(1000); }) }); </script> <style> #content{ text-align: center; background-color: lightblue; border:solid 1px red; display: none; padding: 50px; } </style> </head> <body> <div id="slideDown">出现</div> <div id="slideUp">隐藏</div> <div id="slideToggle">toggle</div> <div id="content">helloworld</div> </body> </html>
相关文章推荐
- android view控件的显示和隐藏动画效果
- <html5+css3+js>用javascript显示隐藏,添加,删除元素,css动画效果
- 动画效果 View控件的显示和隐藏效果
- Android 动画1--View控件的显示和隐藏效果
- Windows界面编程第六篇 动画启动效果(动画效果显示及隐藏窗口)
- jquery 一个简单筛选 显示隐藏效果
- vueJS简单的点击显示与隐藏的效果
- jQuery 效果 - 隐藏hide() 和 显示show()动画实例
- JavaScript之jQuery-5 jQuery 动画效果(隐藏和显示、自定义动画、并发与排列效果)
- 当点击一个View时,显示下面隐藏的一个View(折叠的动画效果)
- 2017/3/10 JQuery 淡出、 动画、显示/隐藏切换等效果
- AngularJS中实现显示或隐藏动画效果的方式总结
- jquery的动画 显示 隐藏 效果 停止
- JQuery 动画显示和隐藏效果
- js菜单点击显示或隐藏效果的简单实例
- jQuery简单实现列表隐藏和显示效果示例
- 2017/3/10 JQuery 淡出、 动画、显示/隐藏切换等效果
- jQuery动画显示和隐藏效果实例演示(附demo源码下载)
- 点击显示隐藏菜单,动画效果,半透明,支持所有浏览器
- 图片的动画效果(淡出,淡入,显示,隐藏等....外加左右移动)(HTML5)