javascript+CSS树形菜单

时间:2022-08-25 20:26:15
javascript+CSS树形菜单<!-- 此树状菜单的原理只要就是利用CSS的display属性,
javascript+CSS树形菜单当display
= " none " 时,就不显示子菜单,当display时,又重新显示子菜单,
javascript+CSS树形菜单只要你搞明白了下面这一段代码,相信你绝对能扩展它的功能,把它做得更复杂点,更美观点,谢谢
javascript+CSS树形菜单可以加上链接,展开时是一种图片,收合时又显示另一种图片,为了使本文更适合初学者,这些代码我就不写了,搞明白下面代码之后你就可以慢慢想如何扩展。。
javascript+CSS树形菜单先给点提示,使用document.getElementById(
" 图片ID " ).src = " 新图片地址 " , 可以动态更换图片
javascript+CSS树形菜单
-->
javascript+CSS树形菜单
<!--
javascript+CSS树形菜单版权信息: javascript
+ CSS树形菜单,
javascript+CSS树形菜单本代码为免费发布,但使用时请勿去除作者版权信息
javascript+CSS树形菜单本声明没有任何法律效力,作为一个程序员,尊重他人版权,也等于尊重自己版权,谢谢合作
javascript+CSS树形菜单作者:王颂元
javascript+CSS树形菜单出处:www.web745.com
javascript+CSS树形菜单
javascript+CSS树形菜单
-->
javascript+CSS树形菜单
< script language = " javascript " >
javascript+CSS树形菜单    
function  change_view(obj_name)
javascript+CSS树形菜单javascript+CSS树形菜单    
... {
javascript+CSS树形菜单        
var aa=document.getElementById(obj_name);
javascript+CSS树形菜单        
if(aa.style.display=="")
javascript+CSS树形菜单javascript+CSS树形菜单        
...{
javascript+CSS树形菜单            aa.style.display
="none";
javascript+CSS树形菜单        }

javascript+CSS树形菜单        
else
javascript+CSS树形菜单javascript+CSS树形菜单        
...{
javascript+CSS树形菜单            aa.style.display
="";
javascript+CSS树形菜单        }

javascript+CSS树形菜单    }

javascript+CSS树形菜单
</ script >
javascript+CSS树形菜单
javascript+CSS树形菜单
< table width = " 160 "  border = " 1 " >
javascript+CSS树形菜单      
< tr onClick = " change_view('a1') " >
javascript+CSS树形菜单        
< td > ●树形菜单根目录1 </ td >
javascript+CSS树形菜单      
</ tr >
javascript+CSS树形菜单     
< tr id = " a1 " style = " display:none " >     <!--  如果想一打开网页菜单就是展开的,此处删除none --->
javascript+CSS树形菜单        
< td >
javascript+CSS树形菜单            
< table width = " 143 "  border = " 0 " >
javascript+CSS树形菜单                  
< tr >
javascript+CSS树形菜单                    
< td width = " 28 " >& nbsp; </ td >
javascript+CSS树形菜单                    
< td width = " 105 " > 二级菜单1 </ td >
javascript+CSS树形菜单                  
</ tr >
javascript+CSS树形菜单                  
< tr >
javascript+CSS树形菜单                    
< td >& nbsp; </ td >
javascript+CSS树形菜单                    
< td > 二级菜单2 </ td >
javascript+CSS树形菜单                  
</ tr >
javascript+CSS树形菜单                  
< tr >
javascript+CSS树形菜单                    
< td >& nbsp; </ td >
javascript+CSS树形菜单                    
< td > 二级菜单3 </ td >
javascript+CSS树形菜单                  
</ tr >
javascript+CSS树形菜单            
</ table >
javascript+CSS树形菜单        
</ td >
javascript+CSS树形菜单  
</ tr >
javascript+CSS树形菜单  
javascript+CSS树形菜单  
javascript+CSS树形菜单    
< tr onClick = " change_view('a2') " >
javascript+CSS树形菜单        
< td > ●树形菜单根目录2 </ td >
javascript+CSS树形菜单      
</ tr >
javascript+CSS树形菜单      
< tr id = " a2 " style = " display:none " >
javascript+CSS树形菜单        
< td >
javascript+CSS树形菜单            
< table width = " 143 "  border = " 0 " >
javascript+CSS树形菜单                  
< tr >
javascript+CSS树形菜单                    
< td width = " 28 " >& nbsp; </ td >
javascript+CSS树形菜单                    
< td width = " 105 " > 二级菜单1 </ td >
javascript+CSS树形菜单                  
</ tr >
javascript+CSS树形菜单                  
< tr >
javascript+CSS树形菜单                    
< td >& nbsp; </ td >
javascript+CSS树形菜单                    
< td > 二级菜单2 </ td >
javascript+CSS树形菜单                  
</ tr >
javascript+CSS树形菜单                   
< tr >
javascript+CSS树形菜单                    
< td >& nbsp; </ td >
javascript+CSS树形菜单                    
< td > 二级菜单3 </ td >
javascript+CSS树形菜单                   
</ tr >
javascript+CSS树形菜单            
</ table >
javascript+CSS树形菜单        
</ td >
javascript+CSS树形菜单  
</ tr >
javascript+CSS树形菜单  
javascript+CSS树形菜单  
javascript+CSS树形菜单    
< tr onClick = " change_view('a3') " >
javascript+CSS树形菜单        
< td > ●树形菜单根目录3 </ td >
javascript+CSS树形菜单      
</ tr >
javascript+CSS树形菜单      
< tr id = " a3 " style = " display:none " >
javascript+CSS树形菜单            
< td >
javascript+CSS树形菜单            
< table width = " 143 "  border = " 0 " >
javascript+CSS树形菜单                  
< tr >
javascript+CSS树形菜单                    
< td width = " 28 " >& nbsp; </ td >
javascript+CSS树形菜单                    
< td width = " 105 " > 二级菜单1 </ td >
javascript+CSS树形菜单                  
</ tr >
javascript+CSS树形菜单                  
< tr >
javascript+CSS树形菜单                    
< td >& nbsp; </ td >
javascript+CSS树形菜单                    
< td > 二级菜单2 </ td >
javascript+CSS树形菜单                  
</ tr >
javascript+CSS树形菜单                  
< tr >
javascript+CSS树形菜单                    
< td >& nbsp; </ td >
javascript+CSS树形菜单                    
< td > 二级菜单3 </ td >
javascript+CSS树形菜单                  
</ tr >
javascript+CSS树形菜单            
</ table >
javascript+CSS树形菜单        
</ td >
javascript+CSS树形菜单  
</ tr >
javascript+CSS树形菜单 
</ table >
javascript+CSS树形菜单
javascript+CSS树形菜单
<!-- 代码结束 -->
javascript+CSS树形菜单