Using jquery scrollTop to position absolute Div

Posted by Tim on Stack Overflow See other posts from Stack Overflow or by Tim
Published on 2010-05-16T04:26:21Z Indexed on 2010/05/16 4:30 UTC
Read the original article Hit count: 340

Filed under:
|

Hello,

I am trying to position an Absolute DIV using Jquery, depending on where the user is clicking on the page.

At the moment this works just great

$('#window').css('left', jsEvent.pageX);
$('#window').css('top', jsEvent.pageY);

This positions the element exactly where my mouse has clicked the screen...

Until you scroll down that is. That is why I am trying to achieve something that will take the amount of pixels from the top of the page into account. I thought something like this...

$('#window').css('top', jsEvent.pageY + scrollTop());

would do the trick, unfortunately it doesn't work.

Any hints?

Thanks,

Tim

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about scrolltop