0

I'm working on a chat app. If you see Facebook chat window, for instance, there is a scrollbar which is initially at the bottom to show the latest message. Similarly, I want to set the div to be initially fully scrolled to the bottom.

How can I set a div with vertical scroll to be fully scrolled to the bottom by default?

Here's my code :

 <div id="divid" style="height:100px; border:2px solid #ccc; overflow: auto;">
     xcv sdf dfg sdfg
     dfg 
     sdf
     g sdfg sdfg sdfg dsfg
     sdfg dgfh dgfh
     dfgh fghdfgh
     gf hdfg hdfgh hgfdgf h
     gfhdgfh 
     dgfhfg
</div>
Markus W Mahlberg
  • 19,711
  • 6
  • 65
  • 89

1 Answers1

0

If my guess is right, you're looking for something like

$('#divid').scrollTop(9999999);
<div id="divid" style="height:100px; border:2px solid #ccc; overflow: auto;">
xcv sdf dfg sdfg
dfg 
sdf
g sdfg sdfg sdfg dsfg
sdfg dgfh dgfh
dfgh fghdfgh
gf hdfg hdfgh hgfdgf h
gfhdgfh 
dgfhfg
Alex
  • 799
  • 5
  • 15
  • I'm working on chating app. if you see facebook chating window, there is scrollbar which is initially at the bottom for showing latest message. Same way I'm showing messages in div and I want to set vertical scroll of that div at bottom. – user1614501 Apr 07 '15 at 16:57
  • That's exactly what @Alex suggested. And the same case shown here: http://stackoverflow.com/questions/10503606/scroll-to-bottom-of-div-on-page-load-jquery – Bruno Toffolo Apr 07 '15 at 17:21