Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 15, 2012 05:04 AM by justdaemon
Member
7 Points
37 Posts
Nov 15, 2012 01:32 AM|LINK
Hi Guys,
I have this DIV that has a certain height that has scroll and my problem is detecting if the vertical scroll has reached the Bottom of the DIV.
Thanks!
All-Star
36852 Points
5446 Posts
Nov 15, 2012 03:05 AM|LINK
pretty trival. try:
<script> $(function() { // create content for (var i=0; i < 100; ++i) { $('#content').append('<div>line' + i + '<div/>'); } // display overflow top and bottom $('#viewport').scroll(function() { var viewportHeight = $('#viewport').height(); var contentHeight = $('#content').outerHeight(true); var scrollTop = $('#viewport').scrollTop(); var scrollBottom = contentHeight - scrollTop - viewportHeight; $('#result').text("top= " + scrollTop + "bottom= " + scrollBottom); }); }); </script> <div id="viewport" style="overflow:auto;height:50px;border:1px solid black;"> <div id="content" style="padding:20px"> </div> </div> <div id="result"></div>
Nov 15, 2012 05:04 AM|LINK
Removed...I discovered the error..My Bad >_<
justdaemon
Member
7 Points
37 Posts
Detect Max Scroll of a DIV
Nov 15, 2012 01:32 AM|LINK
Hi Guys,
I have this DIV that has a certain height that has scroll and my problem is detecting if the vertical scroll has reached the Bottom of the DIV.
Thanks!
bruce (sqlwo...
All-Star
36852 Points
5446 Posts
Re: Detect Max Scroll of a DIV
Nov 15, 2012 03:05 AM|LINK
pretty trival. try:
<script> $(function() { // create content for (var i=0; i < 100; ++i) { $('#content').append('<div>line' + i + '<div/>'); } // display overflow top and bottom $('#viewport').scroll(function() { var viewportHeight = $('#viewport').height(); var contentHeight = $('#content').outerHeight(true); var scrollTop = $('#viewport').scrollTop(); var scrollBottom = contentHeight - scrollTop - viewportHeight; $('#result').text("top= " + scrollTop + "bottom= " + scrollBottom); }); }); </script> <div id="viewport" style="overflow:auto;height:50px;border:1px solid black;"> <div id="content" style="padding:20px"> </div> </div> <div id="result"></div>justdaemon
Member
7 Points
37 Posts
Re: Detect Max Scroll of a DIV
Nov 15, 2012 05:04 AM|LINK
Removed...I discovered the error..My Bad >_<