Skip to content

Instantly share code, notes, and snippets.

@ennjoy
Created May 29, 2019 15:59
Show Gist options
  • Save ennjoy/4202bdb4b9c5c6385f0c6ef4c7eb47d4 to your computer and use it in GitHub Desktop.
Save ennjoy/4202bdb4b9c5c6385f0c6ef4c7eb47d4 to your computer and use it in GitHub Desktop.
up button
<button id="up-btn">Наверх</button>
<script>
var btnUp = document.getElementById('up-btn');
window.onscroll = function() {
var offset = window.pageYOffset;
if(offset > window.innerHeight) {
btnUp.style.display = 'inline';
}
else {
btnUp.style.display = 'none';
}
}
btnUp.onclick = function() {
jQuery('html').animate({scrollTop:0},100);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment