Skip to content

Instantly share code, notes, and snippets.

@Nikschavan
Created April 4, 2018 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nikschavan/a74c9eb2d281235547fba444eb5f1c9f to your computer and use it in GitHub Desktop.
Save Nikschavan/a74c9eb2d281235547fba444eb5f1c9f to your computer and use it in GitHub Desktop.
jQuery(document).on('ready', function(event) {
// Scroll smoothly to anchor
jQuery('a[href^="#"]').on('click', function(event) {
var target = jQuery(this.getAttribute('href'));
if( target.length ) {
event.preventDefault();
jQuery('html, body').stop().animate({
scrollTop: target.offset().top
}, 1000);
}
});
});
@Nikschavan
Copy link
Author

Here is a doc which explains how custom JS can be added to your site - https://wpastra.com/docs/add-custom-javascript-code-astra/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment