4. Working with Events

JavaScript is all about making your pages come alive—but you won’t get very far without events.

Events let you respond to user actions such as clicks, double-clicks, mouse movements, and keystrokes. That’s the kind of thing that JavaScript is good at, and it’s one of the mainstays of jQuery.

Why is event handling so important in jQuery? jQuery unifies event handling in multiple browsers, whereas cross-browser event handling in straight JavaScript is a nightmare.

Event Handling in JavaScript and jQuery

If you’ve ever tried to support, say, drag-and-drop operations in a cross-browser way in straight JavaScript, you know the difficulties. Internet Explorer and Firefox have very different ways of handling events, from top ...

Get jQuery: Visual QuickStart Guide 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.