首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

javascript10.0(承继)

2012-09-15 
javascript10.0(继承)17. JavaScript中的继承。1) 对象冒充htmlheadscript typetext/javascriptfu

javascript10.0(继承)
17. JavaScript中的继承。
1) 对象冒充

<html><head><script type="text/javascript">function Parent(hello) {this.hello = hello;}Parent.prototype.sayHello = function() {alert(this.hello);}function Child(hello, world) {Parent.call(this, hello);this.world = world;}Child.prototype = new Parent();Child.prototype.sayWorld = function() {alert(this.world);}var child = new Child("hello", "world");child.sayHello();child.sayWorld();</script></head><body></body></html>

热点排行