function branch(id, text){
this.id = id;
this.text = text;
this.write = writebranch;
this.add = addleaf;
this.leaves = new array();
this.getid=getid;
}
function getid(){return this.id;}
function addleaf(leaf){
this.leaves[this.leaves.length] = leaf;
}
function writebranch(){
var branchstring =
'< span class="branch" ' + onclick="showbranch(this.getid())"';
//编译的时候出现了this.getid()必须要赋予一个变量的问题,也就是左值问题
求教!!!!!!!!
branchstring += '>< img src="plus.gif" id="i' + this.id + '">' + this.text;
branchstring += '< /span>';
branchstring += '< span class="leaf" id="';
branchstring += this.id + '">';
var numleaves = this.leaves.length;
for (var j=0;j< numleaves;j++) branchstring += this.leaves[j].write();
branchstring += '< /span>';
return branchstring;
}