Skip to content

Instantly share code, notes, and snippets.

@cobaltapps
Created July 21, 2022 21:10
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 cobaltapps/783ca5dcf9a174cd3802f8fe1cc9a4b3 to your computer and use it in GitHub Desktop.
Save cobaltapps/783ca5dcf9a174cd3802f8fe1cc9a4b3 to your computer and use it in GitHub Desktop.
How to override an inline onclick event.
// Setting the DOM element's onclick to null removes the inline click handler
$('#example-button')[0].onclick = null;
// Then you can add your own custom click event function
$('#example-button').click(function() { alert('My Custom Click Event') });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment