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

  • 相关阅读:
    k8s-HPA自动伸缩pod数量
    k8s-命令使用
    k8s-业务镜像版本升级及回滚
    k8s-yml文件详解
    k8s-部署dashboard
    k8s-kubeasz项目后期添加节点及k8s版本升级
    k8s-部署kube dns及coredns
    CDNbest-访问限制
    CDNbest-访问限制
    CDNbest-改变回源host
  • 原文地址:https://www.cnblogs.com/piuba/p/2818336.html
Copyright © 2011-2022 走看看