HomeJavaScript Page 3 - Understanding The JavaScript Event Model (part 1)
Handling Things - JavaScript
This may be news to you, but JavaScript comes with a powerfuland flexible event model, one which provides developers with astandardized way of trapping and handling client-side events likekeystrokes and mouse clicks. This two-part article takes an in-depthlook at how this event model works, demonstrating some practical (andnot-so-practical) uses of the most common event handlers.
Unlike some other programming languages, JavaScript doesn't require you to declare and define functions before they're called. So it's possible to invoke a function via an event handler, and define that function later on in your script - as the following example demonstrates:
If modularizing your code into functions isn't really your cup of tea (why ever not?!), you can even have the JavaScript code accompany the event handler directly.