How to scrollToBottom a div?


#1

Hello,
I want to autoScroll a particular div to bottom whenever a new message is received. The solutions that I found only mentioned scroll for content element. How do I scrollToBottom a div?

<ion-content class="page mc-page">
     
       <div class="chatpanel">

             <!--I want to auto scroll .chattxt-w -->
            <div class="chattxt-w" #chattxt>
                <div class="wtxt s3 msgitem" text-left>This is a sample message</div>
                <!--load all messages-->
                <div class="wtxt s3 msgitem" text-left *ngFor="let msgs of messages">{{msgs.msg}}</div>
            </div>
    
         
        </div>

</ion-content>