<!DOCTYPE html>
<html>
<body>
<button id="button">Click Me</button>
<script type='text/javascript'>
var btnClick = document.getElementById("button");
btnClick.addEventListener("click", func, false);
function func()
{
console.log("This works");
}
</script>
</body>
</html>