Estou aqui a tentar criar uns botões de scroll para uma páginamas estou aqui com uns problemas
Código (Javascript):
index.html
Código (HTML):
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?
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)});
});
});
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>
<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?