hanuman6
6/28/2013 - 1:46 PM

スムーススクロール

スムーススクロール

$('a[href*="#"]').click(function(event){
        event.preventDefault();
        var f = this.href;
        var p = f.split("#");
        var t = p[1];
        var to = $("#"+t).offset();
        var tt = to.top;
        $('html, body').animate({scrollTop:tt},500);
    });
<div id="top">Go to Top<a href="#bottom">bottom</a></div>
<a href="#top" id="bottom">top</a>