【发布时间】:2009-11-24 17:54:26
【问题描述】:
我想下面的代码:
jQuery("#mybutton").click(function(){
//do something
});
我怎么能回忆起这个函数“匿名”?,我不能给这个函数起个名字:
var xfun = function(){
//do something
}
jQuery("#mybutton").click(xfun);
我可以这样做:
var working = false;
jQuery("#mybutton").click(function(){
if (working){
var _this = this;
_this._eventType = e.type;
setTimeout(function() { jQuery(_this).trigger(_this._eventType); }, 200);
return false;
}
//do something
});
我需要的是这样的:
var working = false;
jQuery("#mybutton").click(function(){
if (working){
setTimeout( this_function, 200);
return false;
}
//do something
});
谢谢。
编辑:
解决方案:
jQuery("#mybutton").click(function(){
if (working){
var fn = arguments.callee;
var _this = this;
setTimeout(function(){fn.call(_this);}, 200);
return false;
}
//do something
});
【问题讨论】:
-
@Oscar:问题是“如何从匿名函数内部重新运行匿名函数?”
标签: javascript jquery