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;
});
});
答案 0 :(得分:1)
您需要在$(function(){
来电之前导入jquery库。
在<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
元素中添加<head>
。
此外,.no-touch .vs-container { overflow-x: hidden; }
会阻止在窗口文档上触发滚动事件。