Abhi Burk Abhi Burk - 4 months ago 12
Javascript Question

Want My Scroll Bar always at the bottom but its not working for me

My Html Div In Which Chat is in While Loop So I want My Scroll Always at Bottom But Its Not Working For Me Plz Help Me to Figure it Out

<div class="panel-body">


CSS Code

.panel-body {
padding: 15px;
height: 350px;
overflow: auto;
}


I used two diffrent Given Below Script

1)

$('.panel-body').scrollTop($('.panel-body')[0].scrollHeight);


2)

var myDiv = document.getElementByClassName(".panel-body");
myDiv.scrollTop = myDiv.scrollHeight;

Answer

You can do it easily using javascript...

window.scrollTo(0,document.body.scrollHeight);

See the sample code here...

Comments