Return to Snippet

Revision: 44204
at April 7, 2011 19:53 by Guitaraholic


Initial Code
$(function(){

    $('a[href*=#]').click(function() {
    
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 



        && location.hostname == this.hostname) {
        
            var $target = $(this.hash);
            
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');



            
            if ($target.length) {
            
                var targetOffset = $target.offset().top;
                
                $('html,body').animate({scrollTop: targetOffset}, 1000);



                    
                return false;
                
            }
            
        }
        
    });
    
});

Initial URL
http://elziah.com

Initial Description

                                

Initial Title
Java # smooth scroll to element

Initial Tags
java, jquery

Initial Language
JavaScript