I've been trying to understand how I can convert this tutorial to go for Wordpress. I'm probably doing something wrong with the Javascript - putting it in the wrong place or such.. And I'm not sure if Wordpress already has jQuery script included or not either..
If anyone could help me out I'd be grateful :)
This is the button which I'm putting near the end of my body-tag in index.php:
<a href="#" class="go-top">Go Top</a>
And this is the Javascript which I'm putting just below:
<!-- JavaScript -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
// Show or hide the sticky footer button
$(window).scroll(function() {
if ($(this).scrollTop() > 200) {
$('.go-top').fadeIn(200);
} else {
$('.go-top').fadeOut(200);
}
});
// Animate the scroll to top
$('.go-top').click(function(event) {
event.preventDefault();
$('html, body').animate({scrollTop: 0}, 300);
})
});
</script>