I have a div with following structure.
<div class="span12 sortable ui-sortable">
<div class="box">
<div data-original-title="" class="box-header well">
<h2><i class="icon-edit"></i> All Messages</h2>
</div>
<div class="box-content chatHeight1">
<div id="chtcontent" class="span12">
</div>
<hr/>
</div>
</div>
</div>
I am filling up the div with id -'chtcontent' after getting ajax response. However when the data is more there comes a horizontal scrollbar. So, as per logic, if data is more than the div height it should bring a scrollbar as well as it should focus to the bottom of div.
I tried with followings but its not working.
$('#chtcontent').scrollTop($('#chtcontent')[0].scrollHeight);
var d = $('#chtcontent');
d.scrollTop(d.prop("scrollHeight"));
also tried most of answers in this. Scroll to bottom of Div on page load (jQuery) .But stilll its not working.