目的:由字符串生成树结构,树结构包含在一个div内,该div能独立放置。禁止treeview控件,禁止ActiveX,XP上自带的IE6顺利浏览就可以了。
字符串命名规则:
1.符号“&”为节点分隔符
2.无须根节点,从第一子节点开始遍历,用字符串+数字表示不同的节点,其中字符串是任意的,字符串最后一位不可以包含数字。第i层子节点就有i个数字,同一父节点下的子结点最后一位用数字从小到大标识
3.字符串string113表示的是第一子节点下面的第一个子结点下面的第三个子结点
4.字符串书写顺序为:越是前面的数字越小越优先。如:string123 string1221 string2134 则次序因为 string1221&string123&string2134
例:var treestring
= "book1&history11&historytt111&historygy112&historygypp1121&historygr113&math12&mathadd121&mathplus122&english13&englishds131&englishdsgh1311&plan2e2&do456g3"
通过达人您的手做出的tree.js,我只需调用函数tree(treestring)就可以生成下面的树结构(其中黑色方块为图片,请在您做的js中预留):
■book
■history
■historytt
■historygy
■historygypp
■historygr
■math
■mathadd
■mathplus
■english
■englishds
■englishdsgh
■plan2e
■do456g
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/0196c3df5ea9e936f21e9932cca91014.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/717446ca04a6125dc5b6b54e0fa14ab4.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)