Javascript jQuery方法-移交变量
我正在编写一个插件,我从以下站点获得了基本设置: 如何在方法Javascript jQuery方法-移交变量,javascript,jquery,jquery-plugins,Javascript,Jquery,Jquery Plugins,我正在编写一个插件,我从以下站点获得了基本设置: 如何在方法reset中从init获取变量items 谢谢大家,alex您可以将它们存储在最小的通用范围内,例如方法对象: var methods = { init : function( items ) { /* do stuff */ methods.myData = 15; }, reset : function( name ) { // here I need t
reset
中从init
获取变量items
谢谢大家,alex您可以将它们存储在最小的通用范围内,例如
方法
对象:
var methods = {
init : function( items ) {
/* do stuff */
methods.myData = 15;
},
reset : function( name ) {
// here I need the var items from init
alert(methods.myData * 2); // alerts 30
}
};
var methods = {
init : function( items ) {
/* do stuff */
methods.myData = 15;
},
reset : function( name ) {
// here I need the var items from init
alert(methods.myData * 2); // alerts 30
}
};