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

Javascript
链接渐变效果
两个SUBMIT按钮,如何区分处理
IP地址输入框
无间断滚动marquee的详细用法解析
动态提示的下拉框
在textarea输入Tab
判断file框选择的是否为图片
判断Checkbox和Radio的一种方法
在b/s开发中经常用到的javaScript技术
js获取变量
mouse_on_title.js
Email地址加密javascript版
卡拉 OK 字幕效果
数字金额千位分隔的Javascript
[对联广告] JS脚本类
[原创]图片分页查看
新闻一段时间向上滚动效果
让文字在页面上90度,180度翻转
event.srcElement+表格应用
无限扩展的年份select

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


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