当前位置: 移动技术网 > IT编程>开发语言>Jquery > 返回顶部按钮效果实现

返回顶部按钮效果实现

2018年10月12日  | 移动技术网IT编程  | 我要评论

html:button按钮也可以

<div class="return top_btn ng-scope" style="display: block;"></div>

css:

.return {
    position: fixed;
    right: 2%;
    bottom: 4.6%;
    width: 48px;
    height: 48px;
    background: url(../images/up_top@2x.png);
    background-size: 100% 100%;
    cursor: pointer;
}

 

js:

        $(document).ready(function () {
            $(".top_btn").hide();
            $(function () {
                $(window).scroll(function () {
                    if ($(window).scrolltop() > 100) {
                        $(".top_btn").fadein(1500);
                    } else {
                        $(".top_btn").fadeout(1500);
                    }
                });
                //当点击跳转链接后,回到页面顶部位置
                $(".top_btn").click(function () {
                    $('body,html').animate({
                            scrolltop: 0
                        },
                        1000);
                    return false;
                });
            });
        });

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网