Chapter 4: Reacting to Events with JavaScript and jQuery
In This Chapter
Understanding events
Using JavaScript with forms
Responding to mouse clicks and hovering
Counting characters and disabling a form field
Events are things that happen. For example, the sun rising is an event. The sun setting is an event. You can choose to react to those events. For example, when the sun rises, you might get out of bed — or you might not. When the sun sets, you might turn on a light or might go to bed.
When it comes to web programming, events are the things that happen in a web page. For example, a user might move the mouse over a button, click a button, or submit a form. Like the example of the sun rising, you can choose to react to the event or you can ignore it. If all you wanted to do was ignore events, then this would be a really, really short chapter. But you probably want to react to events, and we show you how to do so for some common scenarios.
Understanding Events
In general, there are four types of events that you’ll be concerned about:
Form events: Includes things like selecting ...