覆盖在jquery闭包中定义的函数 [英] overriding a function defined in jquery closure
本文介绍了覆盖在jquery闭包中定义的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个函数定义在jquery闭包中,并由同一闭包中的另一个函数调用。我可以重写被调用的函数,而不改变闭包本身。请参阅代码示例
I have a function defined in jquery closure and called by another function in the same closure. Could I override the function being called without changing the closure itself. See the code for example
(function($){
function Myfunction(value)
{
//do something with the value
}
$('a').live('click',function(){
MyFunction($(this).val())
});
}(JQuery));
有一种方法可以覆盖 Myfunction
以便在事件处理程序中调用 Myfuntion
的覆盖副本。
is there a way I can override Myfunction
so that overriden copy of Myfuntion
is called inside event handler.
推荐答案
你不能。 闭包中定义的函数为私有,且它们:
[不能]直接从匿名函数之外访问
[cannot] be accessed directly from outside the anonymous function
这篇关于覆盖在jquery闭包中定义的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文