Q&A: Show/Hide DIV on checkbox click
HTML
<div href="" id="button">Show/Hide</div>
<div style="overflow:scroll;height:200px" id="block">
SOOOOOOOOOOME Some text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text hereSome text here</div>
CSS
#block{display:none;background:#eef;padding:10px;text-align:left;white-space:nowrap; overflow-x:hidden; overflow-y:scroll;}
#button {
cursor:pointer;
}
#button:hover {
color:blue;
}
JavaScript
$('#button').click(function() {
if ($('#block').is(':hidden')) {
$('#block').show("blind", function(){
$(this).scrollLeft($(this).data('scroll'));
});
} else {
$('#block').data('scroll',$('#block').scrollLeft());
$('#block').hide("blind");
}
});