Scroll Button Positioning

If you are using scroll for a div that you created, by default the scroll will be at the top of the div. In some cases you may be required to position it to the bottom of the div. For example(happened in my case, if you are creating a chat app, the scroll button needs to be at the bottom(in most cases). You can do this in using simple JavaScript code.

In simple JavaScript:

    var objDiv = document.getElementById("your_div");
    objDiv.scrollTop = objDiv.scrollHeight;

If you are using jQuery, it becomes more easy:

    $("#mydiv").scrollTop($("#mydiv")[0].scrollHeight);
Advertisements

About Odol Shinu

I've completed my B Tech in Information Technology in 2010 from Government Engineering College Sreekrishnapuram Palakkad under Calicut University.

Posted on October 23, 2012, in JavaScript and tagged , , . Bookmark the permalink. Leave a comment.

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

%d bloggers like this: