Html学习笔记5

来源:互联网 发布:淘宝类目007是什么牌子 编辑:程序博客网 时间:2024/05/01 11:26
<!DOCTYPE html><!--JavaScript创建对象JavaScript 的所有数据都可以被视为对象,而每个对象都有其 属性(properties)和 方法(methods)。对象的 属性 是反映该对象某些特定的性质的,例如:字符串的长度、图像的长宽、文字框(Textbox)里的文字等;对象的 方法 能对该对象做一些事情,例如,表单的“提交”(Submit),窗口的“滚动”(Scrolling)等。--><html><head lang="en">    <meta charset="UTF-8">    <title></title>    <script>        /**对象的构造方法,在一开始绘制网页的时候就创建好这个对象的原型,在在后续的会中一个一个的调用即可*/        function student(name,age){            this.name=name;            this.age=age;            this.study=function(){                alert("studying");            };            this.eat=function(){                alert("eating");            }        }    </script></head><body>    <script>        var student_one=new  student("tom",19);        var student_two=new  student("jack",20);        var x=student_one.name;        var y=student_one.age;        document.write(x);        student_one.study();        student_one.eat();        document.write(y);        student_two.study();        student_two.eat();    </script></body></html>
0 0
原创粉丝点击