Consider the following lines of jQuery:
var $s = $('<span><span class="one"><span class="two"></span></span></span>');
$('.one', $s).css('border', 'solid 1px black').scrollLeft(200);
$('.one', $s).css('border', 'solid 1px blue').scrollTop(200);
$(document.body).append($s);
Now I would like to do some scrolling before the elements are attached to the DOM (due to visual requirements), but the scrollbars remain at 0. How can I scroll an element before it is attached to the DOM?
JS Fiddle example: http://jsfiddle.net/KeesCBakker/gQbkw/1/
You can’t scroll an element unless it is attached to the DOM because the browser has no knowledge of it’s dimensions and if it can scroll or how much it can scroll by.