javascript - cant get my div to scroll automatically with the content every time a button is clicked -
cant find solutions here on stack overflow. have div element has content added dynamically. div scrollable once amount of content entered div. i'm trying div scroll down automatically each time content added user not have scroll down manually see new content. here html:
<div class="messagecontainer"> <ul class="messagelist"> <li class="messageitem" ng-repeat="message in messages"> message:<input readonly class="messagetext" ng-model="message.text" ng-change="messages.$save(message)"></input> </li> </ul> </div>
use jquery.animate() everytime new element added.
$('.container').animate({ scrolltop: $(".container div:last-child").offset().top; });
like so: https://jsfiddle.net/gkehnkdk/4/
Comments
Post a Comment