$ .fn.function的调用函数 [英] Calling function of $.fn.function
本文介绍了$ .fn.function的调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题如下. 有一个函数自定义jquery函数,其中包含另一个函数,例如:
The problem is the following. Theres is a function custom jquery function with another function inside, f.e.:
$.fn.slides = function(args){
function foo(args){
}
}
现在我的问题是:如何调用方法foo.
My question is now: How can I call the method foo.
推荐答案
foo
不是方法.它是一个局部函数.除非您修改该函数以使其公开,否则无法从定义该函数的外部访问它.
foo
is not a method. It is a local function. There is no way to access it from outside the function in which it is defined unless you modify that function to expose it.
例如(但我不建议创建全局变量,您应该将函数附加到其他对象):
For example (and I do not recommend creating globals, you should probably attach the function to some other object):
$.fn.slides = function(args){
function foo(args){ }
window.foo = foo;
}
这篇关于$ .fn.function的调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文