jQuery: far scrollare una pagina usando un hash

Possiamo far scrollare una pagina usando un hash con jQuery.

jQuery di Gabriele Romanato

Possiamo far scrollare una pagina usando un hash con jQuery.

La soluzione รจ la seguente:


if( location.hash ) {
    var $target = $( location.hash );
    if( $target.length ) {
        $( "html, body" ).animate( {
            scrollTop: $target.offset().top
        }, 600, "linear" );
    }
}

Commenti