JavaScript 对象的使用

来源:互联网 发布:qq空间病毒式营销源码 编辑:程序博客网 时间:2024/06/05 08:57

示例代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title></title><script type="text/javascript">/* js对象 */function person(id, name) {this.id = id;this.name = name;this.toString = function() {alert(this.id + "," + this.name);}}var p = new person(1001, '张三');p.toString();/* 调用toString方法 */</script></head><body></body></html>

原创粉丝点击