我正在使用jQuery hotkeys plugin ,由 John Resig(jQuery 先生)编写。然而,它使用 bind
,并且 bind
现在被 on
取代,如 the official jQuery API 中所述。 .
标准代码是:
$(document).bind('keyup', 'alt+a', function(evt){...});
我尝试将 bind
更改为 on
,但没有成功。有没有解决方法,或者没有关系?
我还想知道将处理程序附加到文档是否总是最好的方法。
最佳答案
on
采用额外的 DOM 参数 http://api.jquery.com/on/ ,所以写null
。
尝试
$(document).on('keyup', null, 'alt+a', function(){}
关于jQuery 热键插件使用绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14036983/