.change() 和 .on(“change") 之间有区别吗?

问题描述:

有什么区别:

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

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

如果有的话,在大多数情况下我应该使用哪个?

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

没有任何区别,它们都触发了相同的 javascript 函数.您可以在支持 addEventListener 模块的任何浏览器中使用这两者.

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.

查看支持它的浏览器列表:http://caniuse.com/#feat=addeventlistener一个>

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

但是要删除事件,您必须使用 .off( "change" )正如 jquery 文档 所建议的

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

希望能帮到你