经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » JS/JS库/框架 » jQuery » 查看文章
jQuery --- 第四期 (jQuery动效)
来源:cnblogs  作者:CN丶Moti  时间:2019/4/29 10:19:29  对本文有异议

学习笔记

1.jQuery动画的淡入淡出

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>jQuery动画的淡入淡出</title>
  6. <style>
  7. body{background-color: #EBEBEB}
  8. div{
  9. width :200px;
  10. height :200px;
  11. background-color :red;
  12. display :none;
  13. }
  14. </style>
  15. <!--引用jquery库-->
  16. <script src="https://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
  17. <script type="text/javascript">
  18. $(function(){
  19. //动画淡入
  20. $("button").eq(0).click(function(){
  21. $("div").eq(0).fadeIn(2000,function(){
  22. });
  23. });
  24. //动画淡出
  25. $("button").eq(1).click(function(){
  26. $("div").eq(0).fadeOut(2000,function(){
  27. });
  28. });
  29. //淡出入切换
  30. $("button").eq(2).click(function(){
  31. $("div").eq(0).fadeToggle(2000,function(){
  32. })
  33. });
  34. //允许渐变为指定的不透明度(0-1)
  35. $("button").eq(3).click(function(){
  36. $("div").eq(0).fadeTo(2000,0.5,function(){
  37. })
  38. });
  39. });
  40. </script>
  41. </head>
  42.  
  43. <body>
  44. <button>fadeIn</button>
  45. <button>fadeOut</button>
  46. <button>fadeToggle</button>
  47. <button>fadeTo</button>
  48. <div></div>
  49. </body>
  50. </html>

2.jQuery广告弹窗

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>jQuery弹窗广告</title>
  6. <!--适应移动端-->
  7. <meta name="viewport" content="width=device-width, initial-scale=1">
  8. <!--css样式-->
  9. <style>
  10. body{background-color: #EBEBEB}
  11. div{
  12. width :200px;
  13. height :200px;
  14. background-color :red;
  15. position :fixed;
  16. right :0;
  17. bottom :0;
  18. display:none;
  19. }
  20. .span{
  21. width:40px;
  22. height:20px;
  23. position:absolute;
  24. background-color:green;
  25. right:0;
  26. top:0;
  27. }
  28. </style>
  29. <!--引用jquery库-->
  30. <script src="https://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
  31. <script type="text/javascript">
  32. $(function(){
  33. //监听关闭span
  34. $(".span").click(function(){
  35. $("div").fadeOut(1000);
  36. });
  37. //按照动画队列依次执行
  38. $("div").stop().slideDown(1000).fadeOut(500).fadeIn(1000);
  39. });
  40. </script>
  41. </head>
  42.  
  43. <body>
  44. <div>
  45. <span class="span">关闭</span>
  46. </div>
  47. </body>
  48. </html>

 

原文链接:http://www.cnblogs.com/cnmoti/p/10788372.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号