Chapter 4: Reacting to Events with JavaScript and jQuery

In This Chapter

arrow.png Understanding events

arrow.png Using JavaScript with forms

arrow.png Responding to mouse clicks and hovering

arrow.png 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 ...

Get PHP, MySQL, JavaScript & HTML5 All-in-One For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.