Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Click to call – function Reply To: Click to call – function

#166246
Chromawoods
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.