//定义父类
function InputText() {
this.id = '';
this.name = '';
this.type = {'text':'text','password':'password','hidden':'hidden'};
}
//表单元素的前缀名称
InputText.prototype.prefix = 'InputText_';
//定义子类
function InputRadio() {
this.checked = {'false':'false','true':'true'};
}
InputRadio.prototype = new InputText();
InputRadio.prototype.constructor = InputRadio;
InputRadio.prototype.foo = function () { alert(this.prefix);};
//如何获取子类与父类构造函数里面的属性呢?
结果应该是:id,name,type,checked
求达人解决方案....
------解决方案--------------------
function InputText() {
this.id = '';
this.name = '';
this.type = {'text':'text','password':'password','hidden':'hidden'};
}
//表单元素的前缀名称
InputText.prototype.prefix = 'InputText_';
//定义子类
function InputRadio() {
this.checked = {'false':'false','true':'true'};
InputText.call(this);
}
InputRadio.prototype = new InputText();
InputRadio.prototype.constructor = InputRadio;
InputRadio.prototype.foo = function () { alert(this.prefix);};
var a = new InputRadio();
for(i in a){
a.hasOwnProperty(i) && console.log(i);
}