gpt4 book ai didi

jquery - 将多个参数传递给 $.delegate

转载 作者:行者123 更新时间:2023-12-01 08:19:33 27 4
gpt4 key购买 nike

参数来自 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com