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

Javascript
javascript 异常处理使用总结
ExtJS扩展 垂直tabLayout实现代码
JavaScript 新手24条实用建议[TUTS+]
PNG背景在不同浏览器下的应用
实现超用户体验 table排序javascript实现代码
利用JQuery为搜索栏增加tag提示
JQuery 前台切换网站的样式实现
WordPress JQuery处理沙发头像
js form 验证函数 当前比较流行的错误提示
JQuery 无废话系列教程(一) jquery入门 [推荐]
jQuery 表单验证插件formValidation实现个性化错误提示
JQuery 入门实例1
jQuery 可以拖动的div实现代码 修正版
javascript DOM对象的学习实例代码
css 二级菜单 实现代码集合 修正版
ExtJS GTGrid 简单用户管理
jQuery DIV弹出效果实现代码
Javascript 调试利器 Firebug使用详解六
深入javascript json QQ网页登陆
类似新浪网的 弹出视频功能实现代码

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


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