Scrollbar position

My question is related the following fiddle. http://jsfiddle.net/PGuB5/84/

In this fiddle, Click the add row button, the row will be added. The scroll bar will be displayed automatically after some content added.

$('.scrollToBottom').on('click', function() {
    $(".scrollbox").scrollTop($(".scrollbox")[0].scrollHeight);
});

Now I scroll the content at the bottom of the container and click the add row button. The scroll bar position is stay in the bottom.

I want, If I click the add row button, the scroll bar need to move to top.

Answers


For scrolling to top, use :

$('.scrollbox').scrollTop(0);

Updated Fiddle

$('.addrow').on('click', function() {
    $('.scrollbox').append(newline);
    $('.scrollbox').scrollTop(0);
});

Need Your Help

Creating a Many-to-Many Relationship in EF4 Code First

asp.net-mvc-3 entity-framework-4 ef-code-first

I am working on a project in ASP.NET MVC using EF4 Code-First for the modeling. I have the following model classes:

Trying to bind multiple InfoWindows to multiple Markers on a Google Map and failing

javascript ajax json google-maps

My project uses a JSON feed to grab info about earthquakes within a specified latitude and longitude boundary, essentially making a box. I take this info and turn all the results into markers on a

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.