带有插件的jQuery .delegate()? [英] jQuery .delegate() with a plugin?
问题描述
我正在使用名为 jkey 的插件.
I am using a plugin named : jkey.
现在我想将.deligate()与它一起使用.
Now i want to use the .deligate() with it.
此插件的基本语法为:
$(document).jkey('a',function(){
jkey.log('You pressed the a key.');
});
问题 我该如何提供这样的参数?我想发送我尝试执行的键值"a"
QUESTION How do i supply the arguments like in this i want to send the key value 'a' i tried to do this
$("#hmm").delegate(".mm","jkey","a",function() {
$("#get").html("WOW");
});
但失败了
推荐答案
#hmm
必须在开始时出现,并且.mm
是要绑定的内容.您还需要给它一个事件,例如'click'
The #hmm
needs to be present at the start and .mm
is what is being bound. You also need to give it an event for example 'click'
$("#hmm").delegate(".mm","click",function() {
$(this).jkey('a',function(){
jkey.log('You pressed the a key.');
});
});
上面的代码没有多大意义,但是它将侦听ID为"hmm"的现有元素内具有"mm"类的元素的单击.单击后,它将把jkey绑定到.mm元素.
The code above doesn't make much sense but it will listen for a click on an element with class of "mm" inside an existing element with an id of "hmm". Once click, it'll bind jkey to the .mm element.
详细说明您要做什么,我可以举一个更好的例子
Elaborate a bit on what you're trying to do and I can give a better example
这篇关于带有插件的jQuery .delegate()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!