是否可以传递'$(this)'到jQuery中的委托用户函数

Is it possible to pass '$(this)' on to a delegated user function in jQuery?

本文关键字:jQuery 函数 用户 this 是否      更新时间:2023-09-26
function myfunc() {
  alert($(this));
}
$("#SELECTOR").delegate("SELECTOR","click",myfunc);

这是关于点击不同的图像,因此,我真的很喜欢在我的用户函数中使用$(This)变量。

这可能吗?有什么变通办法吗?

是。委托的语法是:

$('#container').delegate('selector','event',function(){
//code to respond to event
});//end delegate

这是你已经拥有的,…

一个工作的例子,其中包括你正在尝试的方法是在这里- http://jsfiddle.net/E9dgU/5/