http://jsfiddle.net/cbp4N/16/
If you show the div. Change the scroll position and then hide and show it agian the scroll position is lost.
am I doing anythi
This is normal behaviour because the element is set to the least possible variables to memory when you hide it. If you want to remember scroll position you'll have to store those yourself and then apply the scroll position on showing it.
Scroll Position of div with "overflow: auto"
Jquery's .scrollTop() works well if you maintain the position as data.
$('#cbxShowHide').click(function(){
if(this.checked) {
$('#block').show('fast',function() {
$(this).scrollTop($(this).data('scroll'));
});
}
else {
$('#block').data('scroll',$('#block').scrollTop());
$('#block').hide('fast');
}
});
example