日期:2014-05-16 浏览次数:20379 次
//定义父类
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);};
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);
}