[英]Simple scroll-to-top script not working
啊,讓我非常沮喪。 我正在嘗試使用簡單的淡入滾動到頂部腳本,但它在我的網站上不起作用,也許有沖突?
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/
您需要在$(function(){
調用之前導入一個jquery庫。
在<head>
元素內添加<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
。
此外, .no-touch .vs-container { overflow-x: hidden; }
.no-touch .vs-container { overflow-x: hidden; }
防止在窗口文檔上觸發滾動事件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.