$(document).ready(function(){
02
    $(".scroll").click(function(event){
03
        //prevent the default action for the click event
04
        event.preventDefault();
05
 
06
        //get the full url - like mysitecom/index.htm#home
07
        var full_url = this.href;
08
 
09
        //split the url by # and get the anchor target name - home in mysitecom/index.htm#home
10
        var parts = full_url.split("#");
11
        var trgt = parts[1];
12
 
13
        //get the top offset of the target anchor
14
        var target_offset = $("#"+trgt).offset();
15
        var target_top = target_offset.top;
16
 
17
        //goto that anchor by setting the body scroll top to anchor top
18
        $('html, body').animate({scrollTop:target_top}, 500);
19
    });
20
});
