Pages

Friday, September 16, 2011

jQuery version of document.scrollIntoView with animation

$('html,body').animate({scrollTop: $([selector]).offset().top-[offsettop]},500);


Where [selector] is the css-patterned name or object (e.g. this ) of the target and [offsettop] is an integer to keep the browser a bit uplifted.

e.g.


$('html,body').animate({scrollTop: $("#description-section").offset().top-20 },500);


No comments :

Post a Comment