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>

posted @ 2011-10-17 19:23  胖鹅  阅读(185)  评论(0编辑  收藏  举报