Created
May 3, 2018 03:46
-
-
Save bjornbennett/6db0110d25aa9219cfaeb83bc88707fb to your computer and use it in GitHub Desktop.
jQuery - trigger events on click of any target class that you add
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
//-------------------------------------------------- | |
// More detailed | |
//-------------------------------------------------- | |
// execute on click | |
$( ".the-target" ).on( "click", function(e) { | |
e.preventDefault(); | |
// do something meaningful... | |
console.log('do something'); | |
}); | |
// attach click event to trigger above | |
$('.the-trigger').click(function(){ | |
$('.the-target').trigger("click"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment