滚动按钮jQuery,用于向上和向下滚动 [英] Scroll button jQuery for scroll up and scroll down

查看:110
本文介绍了滚动按钮jQuery,用于向上和向下滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站上,我有一个项目列表,我在其中使用滚动条来滚动项目.

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.

推荐答案

scrollTop()可以为您提供帮助.请参见文档

scrollTop() can help you here. See the documentation

示例:

$('.scroll-up-button').on('click', function() {
    var scrollIndex = $(window).scrollTop(); // current page position
    $(window).scrollTop(y - 150); // scroll up 150px
}


$('.scroll-down-button').on('click', function() {
    var scrollIndex = $(window).scrollTop(); // current page position
    $(window).scrollTop(y + 150); // scroll down 150px
}

显然,这不是一个完整的解决方案,但是应该可以帮助您正确地开始使用.

Obviously this is not a complete solution, but should help you get started in the correct direction.

这篇关于滚动按钮jQuery,用于向上和向下滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆