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

Javascript
通过JavaScript脚本复制网页上的一个表格
光标定位等TextRange的操作的范例代码
网页与键盘
下拉菜单
点此处秒后立即下载
繁简字转换功能
用javascript制作放大镜放大图片
一个非常强大完整的web表单验证程序Validator v1.05
[原创]checkbox实现全选的多种方法 不断更新
关于IFRAME 自适应高度的研究
document.all还是document.getElementsByName?
光标的帖子总结(Range的使用)
下拉菜单既可以选择,又可以自己填写
用于table内容排序
匹配html标记的正则
图片向上滚动
常用参考资料(手册)下载或者链接
測試代碼真方便
CSS+JS构建的图片查看器
如何实现iframe(嵌入式帧)的自适应高度

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


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