Tree.js
资源名称:a.rar [点击查看]
上传用户:aa118c
上传日期:2021-05-13
资源大小:4785k
文件大小:1k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

HTML/CSS

  1. function Tree(rootNode) {
  2. var $ = this;
  3. this.root = rootNode;
  4. this.show = function(container) {
  5. $.update($.root);
  6. this.root.expand();
  7. if(container.tagName)
  8. container.appendChild($.root.container);
  9. else if(typeof container == "string")
  10. document.getElementById(container).appendChild($.root.container);
  11. }
  12. this.update = function(parent) {
  13. parent.indent();
  14. for (var i = 0; i < parent.children.length; i++) {
  15. parent.children[i].level = parent.level + 1;
  16. for (var j = 0; j < parent.ancestor.length; j++) {
  17. parent.children[i].ancestor.push(parent.ancestor[j]);
  18. }
  19. parent.children[i].ancestor.push(parent);
  20. $.update(parent.children[i]);
  21. }
  22. }
  23. }