0
我有一个小小的椅子计划。当我将鼠标悬停在椅子上时,我用jQuery制作了一个小小的弹出窗口。弹出窗口的位置基于我悬停的椅子的offset()
。jQuery动画/偏移问题
但是,当我滚动时,弹出窗口仍保留在DOCUMENT中的相同位置,但它应该与我悬停的椅子对齐。
$(document).ready(function(){
$(".sp_seat").live('mouseover', function()
{
var id = $(this).attr('id');
var x = $(this).offset().left;
var y = $(this).offset().top;
$('#seat_'+id).css({"left":(x+30)+"px","top":(y+10)+"px"});
$('#seat_'+id).fadeIn('fast');
});
$(".sp_seat").mouseout(function()
{
$('.username').fadeOut('fast');
});
$(".free").click(function()
{
var id = $(this).attr('id');
window.location='?page=event/seatplan&action=pick&seat='+id;
});
});
这是我现在拥有的jQuery代码。
在此先感谢。
这似乎并没有帮助。你能检查一下吗? http://bit.ly/nfNPV4 – Roel
对不起,尝试使用jquery position()而不是offset(),这将获得相对于椅子而不是文档的位置 – Gary