Jump to content

Botões de Scroll


sEnte
 Share

Recommended Posts

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

$(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

<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?

Edited by sEnte

"If It Ain't Broke, Break it and build something Cooler!" Unknown

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.