Ik heb hier en daar wat dingen getest maar werkt niet volgens mij zit er een fout in het scriptcode of er ontbreekt iets.
Kan iemand helpen?
hier is de complete code.
<body>
<style>
.back-to-top {
position: fixed;
bottom: 30px;
right: 30px;
width: 46px;
height: 42px;
z-index: 9999;
cursor: pointer;
text-decoration: none;
transition: opacity 0.2s ease-out;
background-image: url(top.png);
}
.back-to-top:hover{
opacity: 0.7;
}
</style>
<script src='jquery-3.0.0.js' type='text/javascript'></script>
<script>
$(document).ready(function(){
//Check to see if the window is top if not then display button
$(window).scroll(function(){
// Show button after 100px
var showAfter = 100;
if ($(this).scrollTop() > showAfter) {
$('.back-to-top').fadeIn();
} else {
$('.back-to-top').fadeOut();
}
});
//Click event to scroll to top
$('.back-to-top').click(function(){
$('html, body').animate({scrollTop : 0},800);
return false;
});
});
</script>
<a href="#" class="back-to-top"></a>