I'm doing a DOM manipulation in jQuery, wrapping body in some div elements, so I'm trying to match scroll position from window to div element after this transformations, but somehow it doesn't work.
Here's what I'm doing:
scrollPosition = $(window).scrollTop();
myBody = $("body").detach();
myBody.wrapInner("<div class='someclass'><div class='osm-website'></div></div>");
myWebsite = myBody.find('.osm-website');
myWebsite.scrollTop(scrollPosition);
and myWebsite scrollTop position is still 0
but if I do this:
myBody.appendTo('html');
$('.osm-website').scrollTop(scrollPosition);
it works.
I have to find a way to scroll it before appending it to dom because this scroll after appending to page causes a brief "flash" in Safari on Mac. I need it to be seemless.
Any help is greatly appreciated