参数来自 jQuery 作为 $(this)
并包含多个元素:)
尝试过
$('#el').delegate($(this), 'click' ...
$('#el').delegate($(this).each(), 'click' ...
没有工作..
<小时/>(function($){
$.fn.myfunction= function(){
// here i need to somehow find .a, .b., .c etc...
$('#el').delegate($(this), 'click', function(event){
});
});
});
后来我这样调用它:
jQuery(document).ready(function($){
$('.a, .b, .c').myfunction();
});
所以我希望我的事件在所有新的 .a、.b、.c ...
最佳答案
您应该添加一个普通的处理程序:
$(this).bind('click', ...);
您也可以只写$(this).click(...)
.delegate
允许您处理与选择器匹配的元素的子元素中发生的所有事件。
关于jquery - 将多个参数传递给 $.delegate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8116169/