例3-7.htm

来自「web课件并附有习题练习还有实例详细的讲解了WEB的各种开发过程是学习 的好资料」· HTM 代码 · 共 25 行

HTM
25
字号
<html><body><script>
function print()
{ //方法成员定义,输出各属性成员值
  document.write("书名为"+this.name+"<br>");
  document.write("作者为"+this.author+"<br>");
  document.write("出版社为"+this.publisher+"<br>");
  document.write("出版时间为"+this.date+"<br>");
  document.write("印数为"+this.num+"<br>");
}

function book(lname,author,publisher,date,num)
{ //构造函数
  this.name=lname;  	     //书名,属性成员
  this.author=author;  	     //作者,属性成员
  this.publisher=publisher;  //出版社,属性成员
  this.date=date;  	     //出版时间,属性成员
  this.num=num;   	     //印数,属性成员
  this.print=print;          //方法成员
}

var book1=new book("语文","集体编","人民教育出版社","1999",10000);
book_name=book1.name;
book1.print();
document.write("<br>"+book_name);
</script></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?