JS面向对象入门(jquery思想)
<html>
<head>
<TITLE>class_obj_js_class</TITLE>
<script language=javaScript>
var userObj = function(){
};
userObj.prototype={
age:0,
name:"huangbiao",
getUserName:function(){
return this.name;
},
getUserAge:function(){
return this.age;
}
}
function getUserName(){
alert(userObj.prototype.getUserName());
}
function getUserAge(){
alert(userObj.prototype.getUserAge());
}
/*
function ShinyObject(name){
this.name = name;
this.getName = function(){
return this.name;
}
}
var my = new ShinyObject("huangbiao");
var myName = my.getName();
alert(myName);
*/
</script>
<body >
<input type="button" value="getName" onclick="getUserName();"></input>
<input type="button" value="getUserAge" onclick="getUserAge();"></input>
</body>
</html>
回忆过去,珍惜现在,放眼未来