I am trying to popup a div whenever a span with id toolpopup is clicked (div should appear at those coordinates) and it works fine for the spans which are at the top of the page. But when i scroll down and click the span the div is created but not at the desired coordinates. What could be possibly wrong? I am trying it on Firefox 7.0.1
$("#toolpopup").live("click", function(event) {
var X = event.clientX;
var Y = event.clientY;
$("#popup").css('position', 'absolute');
$("#popup").css("top", Y);
$("#popup").css("left", X);
$("#popup").css("display","block");
});
I’m not sure that properly understand your task, but may be you need to append into
XandYa document scroll offset, because:In my code I get scroll offset as:
Then you can set
XandYas: