Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Mahmoud.abdeen93's avatar

how to make the scrollbar always at the bottom of a div?

i am working in a chat app with laravel and i want the scrollbar of the chat box container always in bottom whenever user send a new message and when user enter the chat page

0 likes
3 replies
Mahmoud.abdeen93's avatar

i tried out this piece of code but it didn't work !!

   var element = document.getElementById("message-content");

   element.scrollTop = element.scrollHeight ;
eaglescof's avatar

    <script>
        $('#messages').animate({scrollTop: 9999});
    function scrollDown() {
        $('#messages').animate({scrollTop: 9999}).delay(000);
        $('#messages').animate({scrollTop: 9999});
        }

</script>

Please or to participate in this conversation.