How to define scrollHeight?

How to define scrollHeight for division use css overflow: auto?

I tried:

$('test').scrollHeight(); $('test').height(); but that just returns the size of the div not all the content 

Ultimately, I try to create a chat and always have a scroll bar to the current message on the screen.

So, I thought about the following:

 var test = $('test').height(); $('test').scrollTop(test); 

Thank,

Brian

+54
javascript jquery
Sep 11 '11 at 10:48
source share
2 answers

scrollHeight is a regular javascript property, so you don't need jQuery.

 var test = document.getElementById("foo").scrollHeight; 
+55
Sep 11 '11 at 10:59 a.m.
source share

The correct paths in jQuery are

  • $('#test').prop('scrollHeight') OR
  • $('#test')[0].scrollHeight

Hope this helps.

+201
Mar 13 '13 at 0:59
source share



All Articles