Level 104
Get the last child, and use the scrollIntoView
let el = document.getElementById('communication').lastElementChild;
el.scrollIntoView({behavior: 'smooth'});
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm working on chat application and i would like to scroll down to the last message received, I'm using Vuejs3 Itried a lot of plugins and codes, didnt worked for me this is my div :
<div class="chat-history" style="height: calc(100vh - 60px - 50px);overflow-y: auto;">
<ul class="m-b-0" id="communication">
<li> Msg 1 </li>
<li> Msg 2 </li>
<li> Msg 3 </li>
</ul>
</div>
Get the last child, and use the scrollIntoView
let el = document.getElementById('communication').lastElementChild;
el.scrollIntoView({behavior: 'smooth'});
Please or to participate in this conversation.