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

Javascript
用Javascript 实现的Dual listbox
javascript中的数组应用的一点发现
我与Javascript 随笔(二)
关于IP验证的一个例子
JS中关于对内存的释放问题[待续]
用JScript实现公历到农历的日期转换
判断输入字符串为颜色类型的最优方法
日期控件还是看看这个吧
javascript版的日期输入控件
可输入的select改进版本,同一页面可有多个list,调用接口简化
数字金额转换汉字金额
关于四舍五入的问题,toFixed()
Select的OnChange()事件
关于javascript树形结构的编写问题
将人民币数字转换成大写形式
用JavaScript实现动画效果
javascript: 改变和控制显示的图片大小(保持比例,同时可限制高宽)
超强幻灯片播放脚本(VBS)
HTML页面如何象asp一样接受参数
数字日期转化为汉字日期格式...

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-10   浏览: 234 ::
收藏到网摘: 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;
}