admin管理员组文章数量:1396811
In my site i am having a list of items where i am using scroll bar to scroll the items.
Now i want to replace that bar with two buttons which working for scroll up and scroll down which can auto hide if there is not any item is available to display.
If is there any plugins are available please do let me know.
In my site i am having a list of items where i am using scroll bar to scroll the items.
Now i want to replace that bar with two buttons which working for scroll up and scroll down which can auto hide if there is not any item is available to display.
If is there any plugins are available please do let me know.
Share Improve this question asked Nov 21, 2016 at 10:03 AkashAkash 8403 gold badges14 silver badges38 bronze badges2 Answers
Reset to default 6scrollTop()
can help you here. See the documentation
Example:
$('.scroll-up-button').on('click', function() {
var y = $(window).scrollTop(); // current page position
$(window).scrollTop(y - 150); // scroll up 150px
});
$('.scroll-down-button').on('click', function() {
var y = $(window).scrollTop(); // current page position
$(window).scrollTop(y + 150); // scroll down 150px
});
Obviously this is not a plete solution, but could help you get started in the correct direction.
Use this fiddle
JS:
$(window).scroll(function(){
if ($(this).scrollTop() > 100) {
$('.scrollToTop').fadeIn();
} else {
$('.scrollToTop').fadeOut();
}
});
//Click event to scroll to top
$('.scrollToTop').click(function(){
$('html, body').animate({scrollTop : 0},800);
return false;
});
HTML:
<a href="#" class="scrollToTop">Scroll To Top</a>
CSS:
.scrollToTop{
width:100px;
height:130px;
padding:10px;
text-align:center;
background: whiteSmoke;
font-weight: bold;
color: #444;
text-decoration: none;
position:fixed;
top:75px;
right:40px;
display:none;
}
.scrollToTop:hover{
text-decoration:none;
}
本文标签: javascriptScroll button jQuery for scroll up and scroll downStack Overflow
版权声明:本文标题:javascript - Scroll button jQuery for scroll up and scroll down - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744138706a2592520.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论