Skip to content

Instantly share code, notes, and snippets.

@bjornbennett
Created May 3, 2018 03:46
Show Gist options
  • Save bjornbennett/6db0110d25aa9219cfaeb83bc88707fb to your computer and use it in GitHub Desktop.
Save bjornbennett/6db0110d25aa9219cfaeb83bc88707fb to your computer and use it in GitHub Desktop.
jQuery - trigger events on click of any target class that you add
//--------------------------------------------------
// 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