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

Javascript
JavaScript实际应用:innerHTMl和确认提示的使用
CheckBox 如何实现全选?
解密效果
文本加密解密
快速保存网页中所有图片的方法
如何取得中文输入的真实长度?
Javascript调用XML制作连动下拉列表框
表格轮换显示 强
超级强大的表单验证
图片之间的切换
客户端静态页面玩分页
接收键盘指令的脚本
如果文字过长,则将过长的部分变成省略号显示
些很实用且必用的小脚本代码
经典的带阴影的可拖动的浮动层
漂亮的仿flash菜单,来自蓝色经典
Ctrl+Enter提交内容信息
accesskey 提交
采用CSS和JS,刚好我最近有个站点要用到下拉菜单!
滚动效果

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


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