I have a code like that:
$('#lol').css({ position: "absolute",
marginLeft: 0, marginTop: 0,
top: 0, left: 0});
The problem is that my div is positioned relatively, so it is point 0 of a div rather than the entire window. Why is that?
As pointed out in the other answers, at least one of the parent element of
#lolhas apositionset, that causes your element to be positioned within the parent.A solution with jQuery would be to attach the element directly to body.
This will make it to appear top left of the window.