如何使用JQuery将我的工具提示的最低位置显示在我的链接上?

时间:2010-11-26 11:05:34

标签: jquery

我正在制作一个动态的工具提示...我一直坚持如何让#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-BidHistoryposition:absolute;&有margin-left:300px;

非常感谢任何帮助,谢谢

2 个答案:

答案 0 :(得分:0)

你试过$('a.my-auction-history').offset().top吗?它应该为您提供相对于父<a>元素的位置,即具有position: absolute|relative|fixed的祖先元素,或简称为<body>

答案 1 :(得分:0)

使用.offset()获取相对于文档的a.my-auction-history位置 及其尺寸为.height() and .width()

现在您已经拥有了相对于文档绝对定位工具提示所需的一切