When hovering over a span I would like to get the offsetLeft and offsetTop values so I can make something hover near it. When I do this I get 0 for both values.
What is
$(this).offset().left
and $(this).offset().top
I think you should be able to do this:
HTML
<span class="get-close-to">some username</span><br />
jQuery
jQuery('.get-close-to').hover(function() {
var offset = jQuery(this).css('offset');
alert( 'Left: ' + offset.left + '\nTop: ' + offset.top );
});
Why do you need server-side scripting?
try this:
var positionImg = function(e) {
$(this).offset();
var zoomCntnrPos = $(this).offset.top;
if (zoomCntnrPos >= maxBottomVPos)
{
tPosX = e.pageX;
tPosY = e.pageY +20;
}
else if (zoomCntnrPos <= maxTopVPos){
tPosX = e.pageX;
tPosY = e.pageY +40;
}
else
{
tPosX = e.pageX;
tPosY = e.pageY -100;
}
$zoomContainer.css({top: tPosY, left: tPosX});
};