站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Javascript 专题关于javascript树形结构的编写问题

关于javascript树形结构的编写问题

摘要: 关于javascript树形结构的编写问题


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;
}

</td> </tr> <tr> <td vAlign=top align=left height="100%">
↑返回目录
前一篇: 将人民币数字转换成大写形式
后一篇: 用Javascript和DHTML构建的矢量图形库