JavaScript中创建对象,使用对象
<SCRIPT>var person=new Object();person.name="软件";person.sex="不男不女";person.age="1000";person.sayHelloWorld=function(){ alert("HelloWorld,I'm is "+this.name);}<SCRIPT>呵呵,我们可以这样去添加一个方法:
person.sayHelloWorld=function(){ alert("HelloWorld,I'm is "+this.name);}
哈哈,现在你看见这样的JAVASCRIPT代码,还费解不?
这样在HTML里掉用:
<html><SCRIPT>person.sayHelloWorld();</SCRIPT></html>
页:
[1]