创建继承person的student子类

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>创建继承person的student子类</title>
</head>
<body>
<p>姓名:<span id="name"></span></p>
<p>语文:<span id="chinese"></span></p>
<p>数学:<span id="math"></span></p>
<p>年龄:<span id="age"></span></p>
<script>
function Person(name,chinese,math){
this.name=name;
this.chinese=chinese;
this.math=math;
}
Person.prototype.showName=function(){
return this.name;
};
Person.prototype.showChinese=function(){
return this.chinese;
};
Person.prototype.showMath=function(){
return this.math;
};
function Student(name,chinese,math,age){
Person.call(this,name,chinese,math);
this.age=age;
}
Student.prototype=new Person();
Student.prototype.showAge=function(){
return this.age;
};
var student1=new Student("小盼",98,87,18);
document.getElementById("name").innerHTML=student1.showName();
document.getElementById("chinese").innerHTML=student1.showChinese();
document.getElementById("math").innerHTML=student1.showMath();
document.getElementById("age").innerHTML=student1.showAge();
</script>
</body>
</html>

上一篇:sql server排序规则冲突问题解决


下一篇:java刷题--139单词拆分