關于javascript樹形結構的編寫問題

發表于:2008-05-30來源:作者:點擊數: 標簽:JavaScriptJavascriptjavascript樹形結構
關鍵字: java script 編寫問題 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){
關鍵字:javascript 編寫問題

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;
}

 

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97