本文介绍了当到达底部时,按钮应该隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在jsp页面底部设置了一个按钮。使用该按钮页面将向下滚动。但是当页面到达底部时,我必须隐藏该按钮。此页面是报告页面。所以它包含很多内容。当我到达页面底部时,我必须隐藏按钮。请帮帮我。我是jquery的新手。
我无法找到任何解决方案。
这是我的代码。
$(window).scroll(function(){if($(window).scrollTop()>(#bottomScroll) ){$(#bottom)。addClass('show');} else {$(#bottom)。removeClass('show');};}); jscript:function scrollWin(){window.scrollBy(0,180); }
< script src =https:// ajax .googleapis.com / ajax / libs / jquery / 2.1.1 / jquery.min.js>< / script>< button type =buttononclick =scrollWin()> < img src =Images / aerodown.png>< / button>
div class =h2_lin>解决方案
jQuery
var $ window = $(window),
$ document = $(文件),
按钮= $('。按钮');
button.css({
opacity:1
}); ()($ window.scrollTop()+ $ window.height())== $ document.height() ){
button.stop(true).animate({
opacity:0
},250);
} else {
button.stop(true)。 animate({
opacity:1
},250);
}
});
Am set one button on the bottom in jsp page. Using that button the page will scroll down. But i have to hide that button when the page reach bottom. this page is report page. So it contain lot of contents. I have to hide button when reach the bottom of a page. Please help me. am new to jquery
I was not able to found any solution for this.
Here is my code.
$(window).scroll(function() {
if ($(window).scrollTop() > ("#bottomScroll")) {
$("#bottom").addClass('show');
} else {
$("#bottom").removeClass('show');
};
});
jscript: function scrollWin() {
window.scrollBy(0, 180);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type="button" onclick="scrollWin()">
<img src="Images/aerodown.png">
</button>
解决方案
Demo
jQuery
var $window = $(window),
$document = $(document),
button = $('.button');
button.css({
opacity: 1
});
$window.on('scroll', function () {
if (($window.scrollTop() + $window.height()) == $document.height()) {
button.stop(true).animate({
opacity: 0
}, 250);
} else {
button.stop(true).animate({
opacity: 1
}, 250);
}
});
这篇关于当到达底部时,按钮应该隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!