Quantcast
Channel: Tópicos
Viewing all articles
Browse latest Browse all 14700

Botões de Scroll

$
0
0
Estou aqui a tentar criar uns botões de scroll para uma páginamas estou aqui com uns problemas

Código (Javascript):
$(document).ready(function() {
        var window_height = $(window).height();

        $(window).scroll(function() {
                var scrolled = $(window).scrollTop();
        });

        $('.up').click(function() {
                var scrolled = $(window).scrollTop();
                var document_height = $(document).height();

                $('body').animate({scrollTop: scrolled - (document_height / 10)});
        });

        $('.down').click(function() {
                var scrolled = $(window).scrollTop();
                var document_height = $(document).height();

                $('body').animate({scrolltop: scrolled + (document_height / 10)});
        });

});

index.html
Código (HTML):
<div id="div"></div>
  <div id="button" class="up">/\</div>
  <div id="button" class="down">\/</div>

Esta é a parte que interessa do código javascript

era suposto fazer scroll quando carrego nos botões mas não faz nada.
Podem dar uma ajuda?

Viewing all articles
Browse latest Browse all 14700