zoukankan      html  css  js  c++  java
  • jQuery hover 延时显示$.fn.hoverDelay (fnOver, fnOut,timeIn,timeOut) ;

    先看jQuery hover源代码:


    -----------------------------------------

    (function($) {

        $.fn.hoverDelay = function(fnOver, fnOut,timeIn,timeOut) {

                    var timeIn = timeIn || 200,

                        timeOut = timeOut || 200,

                        fnOut = fnOut || fnOver;

                    var inTimer = [],outTimer=[];

                    

                return this.each(function(i) {

                    $(this).mouseenter(function() {

                            var that = this;

                            clearTimeout(outTimer[i]);

                            inTimer[i] = setTimeout(function() {

                                fnOver.apply(that);

                            }, timeIn);

                      }).mouseleave( function() {

                            var that = this;

                            clearTimeout(inTimer[i]);

                            outTimer[i] = setTimeout(function() {

                                fnOut.apply(that)

                            }, timeOut);

                     });

            })

        }; 

    })(jQuery);

    --------------------------------------------------

    实例:

    --------默认值-------

    $("li").hoverDelay(

      function () {

        $(this).addClass('green');

      }, 

      function () {

        $(this).removeClass('green');

      }

    );

    -------------------------------

    $("li").hoverDelay(

      function () {

        $(this).addClass('green');

      }, 

      function () {

        $(this).removeClass('green');

      },1000,500

    );

    如有错误欢迎指出,共同学习。

    完整测试用例下载:http://115.com/file/c2aun17s#hoverdalay.html

  • 相关阅读:
    诺基亚N900聊QQ的三种方法 狼人:
    VirtualBox安装MeeGo系统黑屏问题处理 狼人:
    android 使用SurfaceView实现小球高处落下并弹起的效果
    【科研论文】新型脉冲电子围栏网络化系统设计
    centos6 yum安装nginx、phpfpm
    windows phone:动画(二)
    Logical Architecture
    xtrabackup全备方案,备份恢复全过程记录
    在Oracle中恢复被DROP掉的表
    JadePool应用范例:创建China软件项目
  • 原文地址:https://www.cnblogs.com/piuba/p/2818336.html
Copyright © 2011-2022 走看看