javascript实现树形菜单的方法
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了javascript实现树形菜单的方法,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2219字,纯文字阅读大概需要4分钟。
内容图文
![javascript实现树形菜单的方法](/upload/InfoBanner/zyjiaocheng/358/178ed12d7dfe4624ae5dd260a4191310.jpg)
本文实例讲述了javascript实现树形菜单的方法。分享给大家供大家参考。具体如下:
var ME={ ini:{i:true,d:{},d1:{},h:0,h1:0,h2:0}, html:function(da,f){ var s='<ul'+(f?' class="f"':'')+'>'; for(var i=0,l=da.length;i<l;i++){ if(typeof(da[i].pid)=='object'){ s+='<li><button type="button" class="'+(i==0&&this.ini.i?'s1':(i+1==l?'s5':'s3'))+'" onclick="ME.yc(this)"></button><span><button type="button" class="r1"></button><a href="javascript:;">'+da[i].ming+'</a></span>'; this.ini.i=false; s+=this.html(da[i].pid,(i+1==l)); }else{ s+='<li><button type="button" class="'+(i+1==l?'e3':'e1')+'"></button><span><button type="button" class="m1"></button><a href="//www.gxlcms.com" target="mainFrame">'+da[i].ming+'</a></span>'; } s+='</li>'; } s+='</ul>'; return s; }, st:function(id,da){ document.getElementById(id).innerHTML=this.html(da); }, yc:function(a){ var s=a.className.substr(1); if(s%2){ this.ini.d=a.parentNode.children[2]; this.ini.h1=this.hei(this.ini.d); this.ini.h3=this.ini.h1/10; this.yc1(1); a.className='s'+(parseInt(s)+1); a.parentNode.children[1].children[0].className='r2'; var ol=a.parentNode.parentNode._; if(typeof(ol)=='object'){ this.ini.d1=ol; this.ini.h=ol.offsetHeight; this.ini.h2=this.ini.h/10; this.yc2(1); ol.parentNode.children[0].className='s'+(parseInt(ol.parentNode.children[0].className.substr(1))-1); ol.parentNode.children[1].children[0].className='r1'; } a.parentNode.parentNode._=a.parentNode.children[2]; }else{ this.ini.d1=a.parentNode.children[2]; this.ini.h=this.ini.d1.offsetHeight; this.ini.h2=this.ini.h/10; this.yc2(1); a.className='s'+(parseInt(s)-1); a.parentNode.children[1].children[0].className='r1'; a.parentNode.parentNode._=''; } }, yc1:function(b){ var h1=ME.ini.h1-(11/(b+1)-1)*ME.ini.h3; with(ME.ini.d.style){ height=h1+'px'; display='block'; } if(b<10){ setTimeout('ME.yc1('+(b+1)+')',25); }else{ ME.ini.d.style.display='block'; ME.ini.d.style.height=''; } }, yc2:function(b){ var h1=(11/(b+1)-1)*ME.ini.h2; with(ME.ini.d1.style){ height=h1+'px'; } if(b<10){ setTimeout('ME.yc2('+(b+1)+')',25); }else{ ME.ini.d1.style.display=''; ME.ini.d1.style.height=''; } }, hei:function(a){ var b=a.cloneNode(true); b.style.position='absolute'; b.style.display='block'; b.style.visibility='hidden'; a.parentNode.appendChild(b); var h=b.offsetHeight; a.parentNode.removeChild(b); return h; } }
希望本文所述对大家的javascript程序设计有所帮助。
内容总结
以上是互联网集市为您收集整理的javascript实现树形菜单的方法全部内容,希望文章能够帮你解决javascript实现树形菜单的方法所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。