当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 关于javascript树形结构的编写问题

Javascript
Javascript实例教程(12) 隐藏script代码
Javascript实例教程(11) 创建\"后退\"按钮
HTC:浏览器上的舞者
JavaScript 小技巧(第四集)
Javascript实例教程(20) 使用HoTMetal(7)
点一下,首页地址添加到收藏夹(javascript)
Javascript设计漫天雪花
Javascript实例教程(21) OLE Automation(2)
Javascript实例教程(20) 使用HoTMetal(3)
Javascript制作闪烁的边框
JavaScript对象与数组参考大全
Javascript实例教程(21) OLE Automation(3)
利用JavaScript制作倒计时牌
Javascript实例教程(5) 利用Javascript创建对象
利用JAVASCRIPT制作简单动画
Javascript实例教程(15) JS代替CGI
Javascript实例教程(19) 数组
JavaScript[对象.属性]集锦之三
Javascript实例教程(21) OLE Automation(6)
JavaScript 小技巧(第一集)

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-10   浏览: 252 ::
收藏到网摘: n/a

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