CSS skills: 2) change hover dynamically by js

//命名空间

var base = {};



//class

base.gClass={};



//鼠标hover交互方法: 注册对象的hover的class特性以及mouseMoveIn,mouseMoveOut方法

base.gClass.hover=(function(creat){

    var creat=function(obj,className,mouseoverFun,mouseleaveFun){

        this.obj=obj;

        this.className=className;

        this.mouseoverFun=mouseoverFun;

        this.mouseleaveFun=mouseleaveFun;



        this.mouseoverFun=='' || this.mouseoverFun == undefined ? this.mouseoverFun=function(){} : void (0);

        this.mouseleaveFun=='' || this.mouseleaveFun == undefined ? this.mouseleaveFun=function(){} : void (0);

    };

    creat.prototype={

        hoverFun:function(){

            var _this=this;

            var obj;

            $(document).on('mouseover',_this.obj,function(e){

                obj= $(this);

                obj.addClass(_this.className);

                _this.mouseoverFun(obj);

            }).on('mouseleave',_this.obj,function(e){

                obj.removeClass(_this.className);

                _this.mouseleaveFun(obj);

            });

        }

    }

    return creat;

})();

 

你可能感兴趣的:(dynamic)