javascript中怎么将一个对象做为另一个对象的属性?(不用JSON方式)
3个回答
展开全部
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>tabindex</title>
<style type="text/css">
</style>
<script type=text/javascript>
function AddProperty() {
var property = document.getElementById("property");
var container = document.getElementById("container");
container.myproperty = property;
}
function ShowProperty() {
var container = document.getElementById("container");
alert(container.myproperty.innerHTML);
}
</script>
</head>
<body>
<input type="button" value="Add property" onclick="AddProperty();" />
<div id="property">abcd</div>
<div id="container">xyz</div>
<input type="button" value="Show property" onclick="ShowProperty();" />
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>tabindex</title>
<style type="text/css">
</style>
<script type=text/javascript>
function AddProperty() {
var property = document.getElementById("property");
var container = document.getElementById("container");
container.myproperty = property;
}
function ShowProperty() {
var container = document.getElementById("container");
alert(container.myproperty.innerHTML);
}
</script>
</head>
<body>
<input type="button" value="Add property" onclick="AddProperty();" />
<div id="property">abcd</div>
<div id="container">xyz</div>
<input type="button" value="Show property" onclick="ShowProperty();" />
</body>
</html>
展开全部
funcion teacher(tno,tname,student){
this.tno = tno;
this.tname = tname;
this.student = student;
}
function student(sno,sname){
this.sno = sno;
this.sname = sname;
}
OK了,还有什么不懂的可以追问
this.tno = tno;
this.tname = tname;
this.student = student;
}
function student(sno,sname){
this.sno = sno;
this.sname = sname;
}
OK了,还有什么不懂的可以追问
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<script>
var A = function(){
this.b='ss'
this.c='tt';
}
var B = function(){
this.a= new A();
}
var mya = new A();
alert(mya.b);
var myb = new B();
alert(myb.a.b)
</script>
var A = function(){
this.b='ss'
this.c='tt';
}
var B = function(){
this.a= new A();
}
var mya = new A();
alert(mya.b);
var myb = new B();
alert(myb.a.b)
</script>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询