在JQuery中何时应该使用.bind()over .click() - 或任何其他给定的事件? [英] In JQuery when should you use .bind() over .click() - or any other given event?
本文介绍了在JQuery中何时应该使用.bind()over .click() - 或任何其他给定的事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我理解Live和Bind之间的区别但是我应该何时使用.bind()而不是'标准'事件方法,如下所示。
I understand the difference between Live and Bind but when should I use use .bind() over a 'standard' event method as shown below.
这两个电话的工作方式是否有任何关键差异?
Are there any key differences in the way these two calls work?
$('.clickme').bind('click', function() {
// Handler called.
});
$('.clickme').click(function() {
// Handler called.
});
推荐答案
它们实际上是一样的。但是,使用 bind()
可以使用命名空间事件。这是在编写插件时特别有用。
They're effectively the same. However, using bind()
allows you to make use of namespaced events. This is especially useful when writing plugins.
这篇关于在JQuery中何时应该使用.bind()over .click() - 或任何其他给定的事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文