Once #theButton is clicked, an alert should be triggered. Why aren’t any of the events being triggered using the following methods?
var theButton = document.getElementById("theButton");
theButton.onclick = function(){alert("Clicked!");}
theButton.onclick = clickAlert;
theButton.onclick(alert("Clicked!"));
function clickAlert(){
alert("Clicked!");
}
</script>
</head>
<body>
<input type="button" id="theButton">
</body>
</html>
You have three problems
functionon line 7. (This generates a runtime error, by the way)onclickproperty on line 8 – not sure if you’re doing that on purpose or what