我有一个JS对象:MyObject = {
InnerObj1 : function() {
this.name = "HelloWorld";
}, InnerObj2 : function() {
this.accessObj1 = function() {
//我要在这里访问到InnerObj1的name属性,这个应该怎么样写??
}
}
}很急,谢谢了!
InnerObj1 : function() {
this.name = "HelloWorld";
}, InnerObj2 : function() {
this.accessObj1 = function() {
//我要在这里访问到InnerObj1的name属性,这个应该怎么样写??
}
}
}很急,谢谢了!
alert(temp.name);
InnerObj1 : function() {
this.name = "HelloWorld";
}, InnerObj2 : function() {
this.accessObj1 = function() {
alert((new MyObject.InnerObj1).name);
}
}
}var obj = new MyObject.InnerObj2;
obj.accessObj1();
this.name = null;
}
MyObject.prototype = {
InnerObj1: function() {
this.name = "HelloWorld";
}, InnerObj2: function() { //alert(this.name)
this.accessObj1 = function() {//搞不懂你这个写这里是做什么
alert(this.name)
}
//this.accessObj1();
}
// ,
// accessObj1: function() {
// alert(this.name)
// }
}
var _MyObject = new MyObject(); _MyObject.InnerObj1();
_MyObject.InnerObj2();
_MyObject.accessObj
this.name = null;
}
MyObject.prototype = {
InnerObj1: function() {
this.name = "HelloWorld";
}, InnerObj2: function() { //alert(this.name)
this.accessObj1 = function() {//搞不懂你这个写这里是做什么
alert(this.name)
}
//this.accessObj1();
}
// ,
// accessObj1: function() {
// alert(this.name)
// }
}
var _MyObject = new MyObject(); _MyObject.InnerObj1();
_MyObject.InnerObj2();
//_MyObject.accessObj();