第四章2

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>第二题</title>
</head>
<body>
<div>
<p>姓名:<span id="name"></span></p>
<p>年龄:<span id="age"></span></p>
<p>自我介绍:<span id="intro"></span></p>
<script>
    function Person(name,age){
        this.name=name;
        this.age=age;
    }
    Person.prototype.showName=function(){
        return this.name;
    }
    Person.prototype.showAge=function () {
        return this.age;
    }
    function Student(name,age,intro){
        Person.call(this,name,age);    //继承属性
        this.intro=intro;
    }
    Student.prototype=new Person();
    Student.prototype.showIntro=function () {
        return this.intro;
    }
    var Student1=new Student("王小明",16,"我是高中一年级的学生,身高1.8米,很帅,我喜欢学习语文和英语。");
    document.getElementById("name").innerHTML=Student1.showName();
    document.getElementById("age").innerHTML=Student1.showAge();
    document.getElementById("intro").innerHTML=Student1.showIntro();
</script>
</div><br>
<div>
    <p>姓名:<span id="name1"></span></p>
    <p>年龄:<span id="age1"></span></p>
    <p>自我介绍:<span id="intro1"></span></p>
    <script>
        function Person(name1,age1){
            this.name1=name1;
            this.age1=age1;
        }
        Person.prototype.showName1=function(){
            return this.name1;
        }
        Person.prototype.showAge1=function () {
            return this.age1;
        }
        function Student(name1,age1,intro1){
            Person.call(this,name1,age1);    //继承属性
            this.intro1=intro1;
        }
        Student.prototype=new Person();
        Student.prototype.showIntro1=function () {
            return this.intro1;
        }
        var Student1=new Student("黄妞妞",6,"我今年6岁了,非常可爱,马上就可以上小学了,就可能有好多好多的小朋友了。");
        document.getElementById("name1").innerHTML=Student1.showName1();
        document.getElementById("age1").innerHTML=Student1.showAge1();
        document.getElementById("intro1").innerHTML=Student1.showIntro1();
    </script>
</div>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值