代码示例
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <h3>我的第一个JavaScript</h3> <p id="demo">一个段落</p> <script> //document.write("你好"); function person(name, age) { this.name=name; this.age=age; this.getName=function(){ return this.name; } this.setName=function(name){ this.name=name; } } var p = new person("liwei",23); alert(p.getName()); </script> </body> </html> |
原文地址:https://www.cnblogs.com/lcs-java/p/8469060.html
时间: 2024-11-07 12:56:17