1
我試圖拼湊下面的代碼,但不起作用。當我向下滾動時,向上翻頁按鈕出現,當我點擊它時,滾動將成爲頁面頂部。當我滾動到頁面頂部時,頁面向下按鈕出現,當我點擊它時,頁面向上滾動時會執行相同的操作。使用javascript上下滾動
var amountScrolledTop = 200;
var amountScrolledDown = 50;
$(window).scroll(function() {
\t if ($(window).scrollTop() > amountScrolledTop) {
\t \t $('a.back-to-top').fadeIn('slow');
\t } else {
\t \t $('a.back-to-top').fadeOut('slow');
\t }
\t if ($(window).scrollTop() < amountScrolledDown) {
\t \t $('a.down1').fadeIn('slow');
\t } else {
\t \t $('a.down1').fadeOut('slow');
\t }
});
$('a.back-to-top').click(function() {
\t $('html, body').animate({
\t \t scrollTop: 0
\t }, 'slow');
\t return false;
});
$('a.down1').click(function() {
\t var objDiv = document.getElementById("mid");
\t objDiv.scrollTop = objDiv.scrollHeight;
});
.down1{
\t width: 60px;
\t height: 60px;
\t text-indent: -9999px;
\t position: fixed;
\t z-index: 999;
\t right: 60px;
\t top: 80px;
\t background: url("../img/simple_icons/downArrow.png") no-repeat center 43%;
}
.back-to-top{
\t display: none;
\t width: 60px;
\t height: 60px;
\t text-indent: -9999px;
\t position: fixed;
\t z-index: 999;
\t right: 20px;
\t bottom: 20px;
\t background: url("../img/simple_icons/upArrow.png") no-repeat center 43%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
\t <a href="#" class="down1" id="down1">Down to</a>
<a href="#" class="back-to-top" id="back-to-top">Back to Top</a>
.
.
.
<div class="mid"></div>
</body>
向下翻頁按鈕始終滾動到頁面頂部。即使我刪除所有的JavaScript代碼。
嘗試清除瀏覽器緩存。 – k97513
嘗試在淡出後設置顯示無... –
您正準確面對的問題是什麼? –