当前位置:   article > 正文

JQuery移动 淡入淡出动画_jquary animation() 淡入淡出

jquary animation() 淡入淡出
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title></title>
  6. <link href="css/demo.css" rel="stylesheet" />
  7. <script src="js/jquery-1.10.2.min.js"></script>
  8. <script src="js/demo.js"></script>
  9. </head>
  10. <body>
  11. <div id="d1"></div>
  12. <button id="btn">按钮</button>
  13. </body>
  14. </html>

demo.js

  1. /// <reference path="jquery-1.10.2.min.js" />
  2. //写jquery的套路 1、页面加载完毕之后 2、找到对象 3、指定相应的事件 4、声明一个事件 5、完成事件里面的内容
  3. $(function () {
  4. $("#d1").click(function () {
  5. $(this).animate({ "left": "200px", "top": "200px" }, 2000, function () {
  6. $(this).animate({ "left": "400px", "top": "0px" }, 2000);
  7. });
  8. });
  9. $("#btn").click(function () {
  10. //alert("hello world");
  11. //$("#d1").hide(1000, function () {
  12. // alert("aaaa");
  13. //});
  14. //$("#d1").show(1000);
  15. // $("#d1").toggle(1000);
  16. //$("#d1").slideUp(1000);
  17. //$("#d1").slideDown(1000);
  18. // $("#d1").slideToggle(1000);
  19. $("#d1").fadeIn(1000);
  20. $("#d1").fadeOut(1000);
  21. $("#d1").fadeToggle(1000);
  22. });
  23. });
demo.css

  1. #d1 {
  2. width: 150px;
  3. height: 150px;
  4. border: solid 2px red;
  5. background-color: #00ff21;
  6. position: absolute;
  7. /*display:none;*/
  8. }
  9. * {
  10. padding: 0px;
  11. margin: 0px;
  12. }



声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/660322
推荐阅读
相关标签
  

闽ICP备14008679号