jQuery : Order of execution of multiple event handlers for same element and event

When you write different event handlers consecutively like below:

$(document).on('submit', 'form', function(){alert('handler1')});
$(document).on('submit', 'form', function(){alert('handler2')});
$(document).on('submit', 'form', function(){alert('handler3')});

They get executed in the way they were bound. The output is

// Alert 1 : handler1
// Alert 2 : handler2
// Alert 3 : handler3

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s