TypechoJoeTheme

A bit of life

登录
用户名
密码

锚点动效

2021-08-09
/
0 评论
/
172 阅读
/
正在检测是否收录...
08/09
        /*锚点动效*/
        $('a[href*=#],area[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 - parseInt(45);
                    console.log(targetOffset);
                    $('html,body').animate({
                            scrollTop: targetOffset
                        },
                        1000);
                    return false;
                }
            }
        });
朗读
赞(0)
版权属于:

A bit of life

本文链接:

http://gxtvb.cn/archives/27/(转载时请注明本文出处及文章链接)

评论 (0)