0
我试图让滚动到顶部按钮出现,一旦用户开始向下滚动,而不是始终存在,即使是在顶部。快速记下,我几乎没有JS的经验,所以我不知道我在做什么。移动网站上的滚动到顶部按钮
反正这里是我在上一个错误的页面:http://www.m.evans-carpentry.com/gallery/projects/
<script>
\t \t \t $(function() {
\t \t \t \t var $elem = $('#content');
\t \t \t \t
\t \t \t \t $('#nav_up').fadeIn('slow');
\t \t \t \t $('#nav_down').fadeIn('slow');
\t \t \t \t
\t \t \t \t $(window).bind('scrollstart', function(){
\t \t \t \t \t $('#nav_up,#nav_down').stop().animate({'opacity':'0.2'});
\t \t \t \t });
\t \t \t \t $(window).bind('scrollstop', function(){
\t \t \t \t \t $('#nav_up,#nav_down').stop().animate({'opacity':'1'});
\t \t \t \t });
\t \t \t \t
\t \t \t \t $('#nav_down').click(
\t \t \t \t \t function (e) {
\t \t \t \t \t \t $('html, body').animate({scrollTop: $elem.height()}, 800);
\t \t \t \t \t }
\t \t \t \t);
\t \t \t \t $('#nav_up').click(
\t \t \t \t \t function (e) {
\t \t \t \t \t \t $('html, body').animate({scrollTop: '0px'}, 800);
\t \t \t \t \t }
\t \t \t \t);
});
</script>
谢谢!
分享你的完整代码,它可以是有希望的。 –
你的jquery文件没有被正确加载。你可能想先把它检查一下。 – Brian
devtools是一个很好的调试工具。你的JS有一些错误,首先要纠正它。例如'$未定义' –