jQuery: more than one handler for same event

flybywire picture flybywire · Sep 29, 2009 · Viewed 115.1k times · Source

What happens if I bind two event handlers to the same event for the same element?

For example:

var elem = $("...")
elem.click(...);
elem.click(...);

Does the last handler "win", or will both handlers be run?

Answer

Russ Cam picture Russ Cam · Sep 29, 2009

Both handlers will run, the jQuery event model allows multiple handlers on one element, therefore a later handler does not override an older handler.

The handlers will execute in the order in which they were bound.