The click event from javascript on a button doesn't fire
So, I was going through a tutorial on event handlers. I created a button
as instructed and then when I click on it, I wanted an alert to be
displayed. Thats it. But it wouldn't work. Here's my html code:
<button id="submit">Submit</button>
And here's my javascript code:
var myButton = document.getElementByID("submit");
myButton.onclick = function(){
alert("YOu clicked on this button");
}
I am using external js file and I've included it in the html from the head
of the document.
No comments:
Post a Comment