Skip to content

Instantly share code, notes, and snippets.

@heyfletch
Last active March 3, 2022 14:54
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 heyfletch/2cbda77de83bbba44e06a949e3db354f to your computer and use it in GitHub Desktop.
Save heyfletch/2cbda77de83bbba44e06a949e3db354f to your computer and use it in GitHub Desktop.
jQuery On Click Scroll to Element and Click
jQuery(function($){ // use $
let myClick = 'a[href^="#guidelines"]';
let myTarget = '#elementor-tab-title-1356';
let mySpeed = 'fast';
let myOffset = 20;
$(myClick).click(function() {
let toScroll = $(myTarget).offset().top - myOffset;
$(myTarget).click();
$('html, body').animate({scrollTop: toScroll}, mySpeed);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment