Event handler allows specified Javascript function to be called when an event such as mouse click, happens. Event handler must be hung onto a DOM tree. For example,
var button = document.geElementById("submitbutton");
button.onclick = function() {...};
Event handler always starts with "on-something". Each element can only has 1 event handler attached to it. If you need to have 2 event handlers, for instance to validate the form and submit to server, you need to use event listener instead.
No comments:
Post a Comment