<input id="elem" type="button" value="Нажми меня" />
<script>
elem.onclick = function() {
alert( 'Спасибо' );
};
</script>
document.addEventListener("DOMContentLoaded", function() {
let butt = document.getElementById("butt");
butt.addEventListener("click", myFunc);
});
function myFunc() {
alert("Done!");
}