如何实现菜单树的折叠与展开?
假设,我有三级菜单页面,一级菜单页面是横放在logo的下面,二三级菜单是放在左边的frame里面,我点击一级菜单,出现有两个按钮,一个是折叠按钮,一个是展开按钮
当我点击折叠按钮时,该一级菜单下面的所有菜单都不显示出来,当我点击展开按钮时,该一级菜单下面的所有菜单及其子菜单都要显示出来,如何处理?javascript代码怎么样写啊?
举例html代码:
<ul><li>1</li> <li><ul> <li>11</li> <li>12</li> <li>13</li> <li>14</li> </ul> </li> <li>2</li> <li><ul> <li>21</li> <li>22</li> <li>23</li> <li>24</li> </ul> </li> <li>3</li> <li><ul> <li>31</li> <li>32</li> <li>33</li> <li>34</li> </ul> </li> </ul>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> <script> function expand(node){ var node=document.getElementById(node); if(node.style.display=="block") node.style.display="none"; else node.style.display="block" } </script> </HEAD> <BODY> <ul><li ondblclick ="expand('first')" style="display: block; cursor : hand; color: red;">1</li> <li id="first"><ul> <li>11</li> <li>12</li> <li>13</li> <li>14</li> </ul> </li> <li ondblclick ="expand('second')" style="display: block; cursor: hand; color: red;">2</li> <li id="second"><ul> <li>21</li> <li>22</li> <li>23</li> <li>24</li> </ul> </li> <li ondblclick ="expand('third')" style="display: block; cursor: hand; color: red;">3</li> <li id="third"><ul> <li>31</li> <li>32</li> <li>33</li> <li>34</li> </ul> </li> </ul> </BODY></HTML>
[解决办法]
用个迭代标签来做啊 http://blog.csdn.net/carefree31441
[解决办法]
不懂帮顶
[解决办法]
我也是同样的问题,up