How to know scroll position reached bottom using jquery

Implemented as below:

Suppose we have a “DIV” tag with some content,

<div id=”scrollbox”>
Lorem ipsum dolor sit amet <br>
Consectetuer augue nibh lacus at <br>
Pretium Donec felis dolor penatibus <br>
Phasellus consequat Vivamus dui lacinia <br>
Ornare nonummy laoreet lacus Donec <br>
Ut ut libero Curabitur id <br>
Dui pretium hendrerit sapien Pellentesque <br>

</div>

We have to add some css stuffs in order to display the vertical scroll, add the below css

#scrollbox{width:200px;height:150px;overflow:auto;}

Then, add javascript snippet

jQuery(
function($)
{
$(‘#scrollbox’).bind(‘scroll’, function()
{
if($(this).scrollTop() + $(this).innerHeight()>=$(this)[0].scrollHeight)
{
alert(‘bottom of div reached’);
}
})
}
);

Thanks. 🙂

Advertisements

2 thoughts on “How to know scroll position reached bottom using jquery

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s