• jQuery 插件代码(收集)


    为jQuery扩展wait方法 [jquery1.4之后添加该方法,但不同版本有不一样的写法]

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gbk" />
        <title>Wait插件演示</title>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
        <style type="text/css">
          div { margin:3px; width:40px; height:40px; position:absolute; left:0px; top:30px; background:green; }
        </style>
      </head>
      <body>
        <div></div>
        <script type="text/javascript">//<![CDATA[
          $.fn.extend({
            wait: function(time, type) {
              return this.queue(type || "fx", function() {
                var $this = $(this);
                setTimeout(function() {$this.dequeue();}, time || 1000);
              });
            }
          });
          (function () {
            $("div").wait()
            .animate({left:'+=200'},2000)
            .wait()
            .animate({left:'-=200'},1500, arguments.callee);
          })();
        //]]></script>
      </body>
    </html>
    View Code

     jQuery.fn.delay

    ---1.4~1.6.4
    function (time, type) {
        time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
        type = type || "fx";
    
        return this.queue(type, function () {
            var elem = this;
            setTimeout(function () {
                jQuery.dequeue(elem, type);
            },
            time);
        });
    }
    ---1.7.0以后
    function (time, type) {
        time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
        type = type || "fx";
    
        return this.queue(type, function (next, hooks) {
            var timeout = setTimeout(next, time);
            hooks.stop = function () {
                clearTimeout(timeout);
            };
        });
    }
  • 相关阅读:
    电路原理图分析
    GPIO学习——用户空间操作
    在Android上运行Java和C程序
    Android命令行工具学习总结
    Android蓝牙学习笔记
    33 把数组排成最小的数
    233 Number of Digit One
    32 从1到n整数中1出现的次数
    31 连续子数组的最大和
    《大型网站技术架构》学习笔记
  • 原文地址:https://www.cnblogs.com/yyman001/p/3377181.html
Copyright © 2020-2023  润新知