Q&A: Show/Hide DIV on checkbox click
HTML
<input type="checkbox" id="cbxShowHide"/><label for="cbxShowHide">Show/Hide</label>
<div style="overflow:scroll;height:200px" id="block">Some text here</br>
Some text here</br>Some text here</br>Some text here</br>Some text here</br>Some text here</br>Some text here</br>Some text here</br>Some text here</br>Some text here</br>Some text here</br>Some text here</br>Some text here</br></div>
</div>
CSS
#block{display:none;background:#eef;padding:10px;text-align:center;}
JavaScript
$('#cbxShowHide').click(function(){
if(this.checked) {
$('#block').show('fast',function() {
$(this).scrollTop($(this).data('scroll'));
});
}
else {
$('#block').data('scroll',$('#block').scrollTop());
$('#block').hide('fast');
}
});