Home › Forums › JavaScript › Click to call – function › Reply To: Click to call – function
March 19, 2014 at 6:21 am
#166246
Participant
If you’re using jQuery:
https://api.jquery.com/on/
For example:
$('#my-element').on('click', myFunction);
If you want to use straight up JavaScript:
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener
Plenty of examples there. For plain JS, your code might need to look different depending on what browsers you need to support.