self指向的是this,该对象是继承tabelBaseCommon的类(this.prototype = new tabelBaseCommon();)
调用:$(“td.hoverTag”).each(function(){ var $this = $(this); self.prototype.titTagHover({ hoverControl: $this, tagControl: $this.children(“div.titTag”), location: { x: 45, y: -10 }, positon: “position” }); }); 定义:/悬停在hoverControl上显示小提示功能/ /* 参数:{hoverControl:$(td),tagControl:$(xx),position:{x:0,y:0}} */ tabelBaseCommon.prototype.titTagHover = function (o) { if (!o.hoverControl || !o.tagControl) return; var o = $.extend({ location: { x: 0, y: 0 }, positon: “position” }, o); o.hoverControl = $(o.hoverControl); o.tagControl = $(o.tagControl); o.hoverControl.unbind(“mouseenter”).unbind(“mouseleave”).hover(function () { var $this = $(this); var offset = $this.offset(); if (o.positon == “position”) { var realX = o.location.x; var realY = o.location.y; } else { var realX = offset.left + o.location.x; var realY = offset.top + o.location.y; } o.tagControl.css({ "left": realX + "px", "top": realY + “px” }); o.tagControl.show(); }, function () { o.tagControl.hide(); }); }