var obj = $(".tip2-bx"),other = $(".enter"),time function effect(){ var _this = this; this.other = other; this.obj = obj; other.hover( function(){ _this.show($(this)) }, function(){ _this.hide($(this)) } ) obj.hover( function(){ clearTimeout(time) }, function(){ obj.css({"visibility":"hidden"}) } ) } effect.prototype = { show:function(o){ clearTimeout(time) this.obj.css({"visibility":"visible","top":o.offset().top+20,"left":o.offset().left-35}); }, hide:function(o){ time = setTimeout(function(){this.obj.css({"visibility":"hidden"});},500) } } var n = new effect();