How can I move to <a name tag slowly?

This question already has an answer here:

  • jQuery scroll to element 24 answers

  • This is quite easy to do with jQuery by animating the scrollTop of the html and body :
    http://css-tricks.com/snippets/jquery/smooth-scrolling/

    Here's a snippet from a comment on that page:

    $('a[href*=#]:not([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) {
                 $('html,body').animate({
                     scrollTop: target.offset().top
                }, 1000);
                return false;
            }
        }
    });
    
    链接地址: http://www.djcxy.com/p/23092.html

    上一篇: 问题滚动到表中的一行

    下一篇: 我怎样才能移动到<名称标签缓慢?