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

这个问题在这里已经有了答案:

  • jQuery滚动到元素24的答案

  • 通过对htmlbodyscrollTop进行动画处理,这对jQuery scrollTop很容易:
    http://css-tricks.com/snippets/jquery/smooth-scrolling/

    以下是该页面评论的摘录:

    $('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/23091.html

    上一篇: How can I move to <a name tag slowly?

    下一篇: Javascript (preferably Jquery) that will mimic behavior of hashtags