function myfunc() {
alert($(this));
}
$("#SELECTOR").delegate("SELECTOR","click",myfunc);
这是关于单击不同的图像,因此,我真的很想在我的用户函数中使用 $(this) 变量。
这可能吗?有什么解决办法吗?
最佳答案
是的。委托(delegate)的语法是:
$('#container').delegate('selector','event',function(){
//code to respond to event
});//end delegate
这几乎是你已经拥有的,..
这里有一个包含您正在尝试的方法的工作示例 - http://jsfiddle.net/E9dgU/5/
关于javascript - 是否可以将 '$(this)' 传递给 jQuery 中的委托(delegate)用户函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15777380/