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

Javascript
jQuery Selectors(选择器)的使用(七、子元素篇)
jquery 事件执行检测代码
javascript 支持页码格式的分页类
javascript tabIndex属性
jquery tablesorter.js 支持中文表格排序改进
javascript 返回数组中不重复的元素
javascript 文字上下间隔滚动的代码 符合WEB标准 脚本之家修正版
jQuery 开天辟地入门篇一
jMessageBox 基于jQuery的窗口插件
用javascript获取当页面上鼠标光标位置和触发事件的对象的代码
javascript实现的textarea运行框效果代码 不用指定id批量指定
测试你的JS的掌握程度的代码
js 与或运算符 || && 妙用
模仿JQuery.extend函数扩展自己对象的js代码
json 介绍 js简单实例
Ext.MessageBox工具类简介
ASP小贴士/ASP Tips javascript tips可以当桌面
勾选时激活input 否则禁用的javascript代码
javascript 输入文本框时的友好提示
jValidate 基于jQuery的表单验证插件

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


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