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

Javascript
Javascript解决常见浏览器兼容问题的12种方法
用AJAX返回HTML片段中的JavaScript脚本
javascript splice数组简单操作
jQuery 数据缓存data(name, value)详解及实现
javascript下动态this与动态绑定实例代码
javascript forEach函数实现代码
javascript bind绑定函数代码
javascript当onmousedown、onmouseup、onclick同时应用于同一个标签节点Element
jQuery DOM操作小结与实例
Extjs学习笔记之一 初识Extjs之MessageBox
Extjs学习笔记之二 初识Extjs之Form
Extjs学习笔记之三 extjs form更多的表单项
Extjs学习笔记之四 工具栏和菜单
EXT中xtype的含义分析
Extjs学习笔记之五 一个小细节renderTo和applyTo的区别
jQuery DOM操作 基于命令改变页面
让多个输入框中的内容同时变化的js代码
判断iframe是否加载完成的完美方法
IE iframe的onload方法分析小结
javascript new一个对象的实质

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


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