Reputation: 70
$("#wrapper").scrollTop($("#wrapper").scrollTop()+$("div.element.active").position().top);
})
http://jsfiddle.net/yuFk5/250/
This script includes a workaround to allow scrolling with overflow hidden, but I am getting confused about how to implement animate into this to give the animation a duration.
Upvotes: 0
Views: 251
Reputation: 7199
Based off the code in your jsFiddle
$( document ).ready(function() {
$("#foo").click(function() {
$("#wrapper").animate({'scrollTop': $("#wrapper").scrollTop()+$("div.element.active").position().top}, 400);
})
});
Upvotes: 3