我正在制作一个动态的工具提示...我一直坚持如何让#MyAuction-BidHistory
的最低位置显示在我的链接a.my-auction-history
上方?
到目前为止,这是我的代码:
var linkOffset = $('a.my-auction-history').offset().top;
$('.my-auction-history').mouseover(function(e){
$.get('/auction/includes/new-bidhistory.asp?lplateid=' + pListedPlatesId + "&xx=" + t, function(data){
$('#MyAuction-BidHistory').css({'display':'block', 'opacity':'0', 'top':linkOffset }).animate({opacity:1}, 200).html(data);
});
});
我只需要计算Y坐标#MyAuction-BidHistory
已position:absolute;
&有margin-left:300px;
非常感谢任何帮助,谢谢
答案 0 :(得分:0)
你试过$('a.my-auction-history').offset().top
吗?它应该为您提供相对于父框的<a>
元素的位置,即具有position: absolute|relative|fixed
的祖先元素,或简称为<body>
。
答案 1 :(得分:0)
使用.offset()获取相对于文档的a.my-auction-history
位置
及其尺寸为.height() and .width()
现在您已经拥有了相对于文档绝对定位工具提示所需的一切