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

Javascript
让您的菜单不离网站
JavaScript去除空格的几种方法
TFDN图片播放器 不错自动播放
通过ifame指向的页面高度调整iframe的高度
解放web程序员的输入验证
让背景如此暗淡(一种弹出提示信息时页面背景色调改变的方法)
关于textarea的直观换行的一些研究材料
网页缓存文件批量改名工具
按钮里的字可以换行吗
许愿墙中用到的函数
自动更新作用
激活 ActiveX 控件
使用Javascript和DOM Interfaces来处理HTML
获取DOM对象的几种扩展及简写
splice slice区别
Array.slice()与Array.splice()的返回值类型
$$()函数应用实例
window.open的功能全解析
点击单元格后可编辑单元格内文本如何制作
用JavaScript脚本实现Web页面信息交互

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


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