简单的滚动到顶部脚本不起作用



啊,让我非常沮丧。我正在尝试使用简单的淡入滚动到顶部脚本,但它在我的网站上不起作用,也许存在冲突?

.HTML:

 <a href="#" class="scrollup">Scroll</a>

.CSS:

.scrollup{
width: 15px;
height: 15px;
position: fixed;
top: 50px;
left: 15%;
display: none;
text-indent: -9999px;
background: url('../images/arrow.png') no-repeat;
z-index: 5000;
}

JQUERY:

$(document).ready(function(){ 
    $(window).scroll(function(){
        if ($(this).scrollTop() > 100) {
            $('.scrollup').fadeIn();
        } else {
            $('.scrollup').fadeOut();
        }
    }); 
    $('.scrollup').click(function(){
        $("html, body").animate({ scrollTop: 0 }, 600);
        return false;
    });
});

网站: http://kaye.at/test/

在调用之前,您需要导入 jquery 库$(function(){

<head>元素中添加<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

此外,.no-touch .vs-container { overflow-x: hidden; }可防止在窗口文档上触发滚动事件。

最新更新