L. Techer L. Techer - 1 year ago 75
jQuery Question

Is there a difference between .change() and .on("change")?

Is there any difference between :

$('selector').change(function() {});


$('selector').on("change", function() {});

And if there is, which one should I use in most cases?

Answer Source

The is no difference at all, they both trigger the same javascript function. You can use both in any browser that supports the addEventListener modules.

Check the list of browsers that support it: http://caniuse.com/#feat=addeventlistener

However to remove the event, you'll have to use .off( "change" ) as the jquery doc suggests

Hope it helps

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download