Return to Snippet

Revision: 57596
at June 2, 2012 14:48 by thewickedchemist


Initial Code
$(function($) {
    $(".scroll a, .top-btn").click(function(event) {
        event.preventDefault();
        $('html,body').animate({
            scrollTop: $(this.hash).offset().top
        }, 500);
    });
});​

//usage

<a href="#theContent">Scroll to content</a>


<div id="theContent">
   blah blah blah
</div>

Initial URL

                                

Initial Description
Simply set the id in the content, and use a hash in the anchor to scroll to it.

Initial Title
Smooth Scrolling to Any ID

Initial Tags
jquery

Initial Language
jQuery