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

Javascript
RDF:Web数据集成的元数据解决方案
你的IP
弹出精彩-弹出式菜单详解
在Web网页上使用VBScript 和JScript
图档结构树的设计与关联
JavaScript电子表
输入日期之改进模式
如果你想打开一个新页面时给浏览者一些惊喜的话,试试这个
HTML文档中用JavaScript调用Microsoft Agent的COM接口编程
JavaScript修改注册表
JavaScript构造XML树结构
一个很不错的主页效果。。你试试!!!
一个用js加密的好玩的东东
在网页上显示一个会移动的透明时钟的代码。。。
如何显示年月日及星期问题
javascript手冊-c
javascript手冊-d
javascript手冊-f
javascript手冊-g
javascript手冊-i

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


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