直接看代码:
如下
$(function(){
var personVo = new Person("idtest","nametest");alert(personVo.id+";"+personVo.name);
personVo.setId("testPersonId");
alert(personVo.getValue());
});
var Person = function(id, name){ // 声明函数
this.id = id;
this.name = name;
};
Person.prototype={ //再对函数设置属性
getValue: function(){
return this.id+";"+this.name;
},
setId:function(id){
this.id = id;
}
}