Skip to content

Instantly share code, notes, and snippets.

@guilhermealveslopes
Created April 21, 2017 23:45
Show Gist options
  • Save guilhermealveslopes/1f6e6f2bce3d50d78c836d89d1eac067 to your computer and use it in GitHub Desktop.
Save guilhermealveslopes/1f6e6f2bce3d50d78c836d89d1eac067 to your computer and use it in GitHub Desktop.
Anchor Scroll
<script>
jQuery(document).ready(function($){
$(function() {
$('.menu-interno li a').click(function() { /* Define o elemento do clique */
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;
}
}
});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment