redhightree 2010-05-04
代码如下:
cnblogs.news.Article=function(){
var _this=this;
this.title=null;
this.content=null;
this.show=function(){
document.write("<h1>"+_this.title+"</h1>");
document.write("<p>"+_this.content+"</p>");
}
} 代码如下:
// 实例化一个对象 var article =new cnblogs.news.Article(); // 给对象的属性赋值 article.title="这是文章标题"; article.content="这是文章内容"; // 调用对象的方法 article.show();
代码如下:
cnblogs.news.Article={
title:"这是文章标题",
content:"这是文章内容",
show:function(){
document.write("<h1>"+cnblogs.news.Article.title+"</h1>");
document.write("<p>"+cnblogs.news.Article.content+"</p>");
}
};