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

Javascript
让innerHTML的脚本也可以运行起来
nextSibling
限制复选框的最大可选数
onpropertypchange
让焦点自动跳转
显示、隐藏密码
textarea是否自动换行
鼠标图片振动代码
对联浮动广告效果
一段实时更新的时间代码
让广告代码不再影响你的网页加载速度
载入进度条 效果
二级连动菜单
如何实现浏览器上的右键菜单
html代码调试脚本
表单提交验证类
简单实用的网页表格特效
表单的一些基本用法与技巧
Javascript - HTML的request类
教学演示-UBB,剪贴板,textRange及其他

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


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