Scrolling scrollable Div and Get Scroll Value using javascript JQuery


Here is my very simple sample code about scrolling html div using jquery:

<div id=”maincontainer” style=”width: 100%; height: 100%; overflow: auto;” >

</div>

$(‘div#maincontainer’).scroll(function(){ //event triggered by scrolling action
alert($(this).scrollTop()); //get div scroll value
});

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s