js面向对象方法写的树怎么实现getParent()方法 var branch1 = new branch('branch1','javascript参考书'); branch1生成了么? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你可以在branch和leaf的构造函数里面加个指针指向父节点,而不是加获取父节点的函数在生成branch或者leaf时把父节点作为参数传入如function branch(id, text, checked,pNode){ this.id = id; this.text = text; this.add = addLeaf; this.leaves = new Array(); this.write = writeBranch; this.getChildren = getChildren; //this.getParent = getParent(id); //===> this.parentNode=pNode; this.checked = checked; } var myTree = new tree(); var branch1 = new branch('branch1','javascript参考书',myTree); 上班不能使用qq,下班了又没空使用qq,嘿嘿 求助网页JS中路径的\替换成为\\,为什么只有最前面的被替换成功 js能多个变量同时定义赋值吗? 在线等, 马上结贴. 为什么循环只执行了一次? java里有没有转换16进制到10进制,10进制转换成16进制的函数 求助:如何删除超链接 有关刷新的问题。 如何new出一个新的窗口,而原来的窗口自动关闭? 大哥们,帮帮小妹把,下面这个动态效果如何实现 动态列表框状态保存问题?分不够可以在给! 父-子-孙 三个窗口的互访问题。用iframe,相互值传递问题。 数据table之间的移动(可能没解释清楚,请进帮忙) ext中的TabPanel的选项卡能不能销毁
function branch(id, text, checked,pNode){
this.id = id;
this.text = text;
this.add = addLeaf;
this.leaves = new Array();
this.write = writeBranch;
this.getChildren = getChildren;
//this.getParent = getParent(id);
//===>
this.parentNode=pNode;
this.checked = checked;
} var myTree = new tree();
var branch1 = new branch('branch1','javascript参考书',myTree);