1<div class="first"><button type="button" onclick="smoothScroll(document.getElementById('second'))">Click Me!</button></div>
2<div class="second" id="second">Hi</div>
3
1$("button").click(function() {
2 $('html,body').animate({
3 scrollTop: $(".second").offset().top},
4 'slow');
5});
6
7// example: http://jsfiddle.net/ryXFt/3/
1$(window).scroll(function() {
2 $('html, body').animate({
3 scrollTop: $("#myDiv").offset().top
4 }, 2000);
5});