document.getElementById("ELEMENT_ID").addEventListener("click", function() {
//insert here the code to be executed
});
//html
<button>My Button</button>
document.querySelector("button").addEventListener('click', handlClick);
function handlClick() {
alert("I got clicked!")
}