Created
August 19, 2020 09:52
-
-
Save leogono/9c0ce0eb00e34aad34ed76f61ee2ae63 to your computer and use it in GitHub Desktop.
button click js listener
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
// HTML | |
// <a href="javascript:void(0)" id="click-this">Click this</a> | |
let button = document.getElementById('click-this'); | |
button.addEventListener('click', function(ev) { | |
onClick(); | |
}); | |
function onClick() { | |
alert('Button clicked'); | |
//or do something... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment