Last active
March 3, 2022 14:54
-
-
Save heyfletch/2cbda77de83bbba44e06a949e3db354f to your computer and use it in GitHub Desktop.
jQuery On Click Scroll to Element and Click
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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