table的td相对定位:小提示的js
发布于 10 年前 作者 sdfcbs91 4356 次浏览 最后一次编辑是 8 年前

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(); }); }

回到顶部