Skip to content

Instantly share code, notes, and snippets.

@koentjuh1
Created August 3, 2016 17:18
Show Gist options
  • Save koentjuh1/f236f624af69872efc24d8d0470ee06f to your computer and use it in GitHub Desktop.
Save koentjuh1/f236f624af69872efc24d8d0470ee06f to your computer and use it in GitHub Desktop.
<html lang="nl-NL" id="top">
<div class="back-to-top">
<a href="#top" class="btn-top"><i class="fa fa-angle-up"></i></a>
</div>
</html>
$(document ).ready(function() {
$('.footer-btn a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment