<div class="htmlarea"> <textarea id="runcode27253"> <meta charset="utf-8"> <title>无限级折叠菜单 1.01 JS版</title> <meta name="keywords" content="hj1227 原创无限级折叠菜单 1.01js版"> <meta name="description" content="hj1227 原创无限级折叠菜单 1.01js版"> <style> <!-- 몸체,ul,h3 {마진:0px; 패딩:0px;} 리 {목록 스타일 유형:없음;} 몸{ 글꼴 크기:12px; 색상:#333; 글꼴 모음: Simsun; 줄 높이:15px; } a{텍스트 장식:없음;색상:#004285;경계:없음;} a:hover{텍스트 장식:없음;색상:#C33;} #메뉴 { 너비:260px; 여백:50px 자동; 패딩:10px; 테두리:#EEE 1px 솔리드; } #메뉴 h3 { 글꼴 크기:12px; } #메뉴 ul { 배경:url("http://demo.jb51.net/js/2011/caidan/ul-bg.gif") 반복-y 5px 0px; 오버플로:숨김; } #메뉴 울 리 { 패딩:5px 0 2px 15px; 배경:url("http://demo.jb51.net/js/2011/caidan/tree-ul-li.gif") 반복 없음 5px -32px; } #menu ul li ul {display:none;} #menu ul li em { 커서:포인터; 디스플레이:인라인 블록; 너비:15px; 부동:왼쪽; 높이:15px; 여백-왼쪽:-14px; 배경:url("http://demo.jb51.net/js/2011/caidan/tree-ul-li.gif") no-repeat -32px 2px; } #menu ul li em.off { 배경 위치: -17px -18px; } #menu ul li#end { 배경색:#FFF; } #메뉴 ul.off { 표시:블록; }--> </style> <div id="menu"> <h3>무한 접기 메뉴 1.0.1 JS 버전 </h3> <ul> <li> <em></em><a href="javascript:void(0);">메뉴_1_1</a> <ul> <li> <em></em><a href="javascript:void(0);">메뉴_2_1</a> <ul> <li> <em></em><a href="javascript:void(0);">메뉴_3_1</a> <ul> <li> <em></em><a href="javascript:void(0);">메뉴_4_1</a> <ul> <li><a href="javascript:void(0);">메뉴_5_1</a></li> <li id="end"><a href="javascript:void(0);">메뉴_5_2</a></li> </ul> </li> <li id="end"> <em></em><a href="javascript:void(0);">메뉴_4_2</a> <ul> <li><a href="javascript:void(0);">메뉴_5_1</a></li> <li id="end"><a href="javascript:void(0);">메뉴_5_2</a></li> </ul> </li> </ul> </li> <li id="end"> <em></em><a href="javascript:void(0);">메뉴_3_2</a> <ul> <li> <em></em><a href="javascript:void(0);">메뉴_4_1</a> <ul> <li><a href="javascript:void(0);">메뉴_5_1</a></li> <li id="end"><a href="javascript:void(0);">메뉴_5_2</a></li> </ul> </li> <li id="end"> <em></em><a href="javascript:void(0);">메뉴_4_2</a> <ul> <li><a href="javascript:void(0);">메뉴_5_1</a></li> <li id="end"><a href="javascript:void(0);">메뉴_5_2</a></li> </ul> </li> </ul> </li> </ul> </li> <li id="end"> <em></em><a href="javascript:void(0);">메뉴_2_2</a> <ul> <li> <em></em><a href="javascript:void(0);">메뉴_3_1</a> <ul> <li> <em></em><a href="javascript:void(0);">메뉴_4_1</a> <ul> <li><a href="javascript:void(0);">메뉴_5_1</a></li> <li id="end"><a href="javascript:void(0);">메뉴_5_2</a></li> </ul> </li> <li id="end"> <em></em><a href="javascript:void(0);">메뉴_4_2</a> <ul> <li><a href="javascript:void(0);">메뉴_5_1</a></li> <li id="end"><a href="javascript:void(0);">메뉴_5_2</a></li> </ul> </li> </ul> </li> <li id="end"> <em></em><a href="javascript:void(0);">메뉴_3_2</a> <ul> <li> <em></em><a href="javascript:void(0);">메뉴_4_1</a> <ul> <li><a href="javascript:void(0);">메뉴_5_1</a></li> <li id="end"><a href="javascript:void(0);">메뉴_5_2</a></li> </ul> </li> <li id="end"> <em></em><a href="javascript:void(0);">메뉴_4_2</a> <ul> <li><a href="javascript:void(0);">메뉴_5_1</a></li> <li id="end"><a href="javascript:void(0);">메뉴_5_2</a></li> </ul> </li> </ul> </li> </ul> </li> </ul> </li> <li id="end"> <em></em><a href="javascript:void(0);">메뉴_1_2</a> <ul> <li> <em></em><a href="javascript:void(0);">메뉴_2_1</a> <ul> <li> <em></em><a href="javascript:void(0);">메뉴_3_1</a> <ul> <li> <em></em><a href="javascript:void(0);">메뉴_4_1</a> <ul> <li><a href="javascript:void(0);">메뉴_5_1</a></li> <li id="end"><a href="javascript:void(0);">메뉴_5_2</a></li> </ul> </li> <li id="end"> <em></em><a href="javascript:void(0);">메뉴_4_2</a> <ul> <li><a href="javascript:void(0);">메뉴_5_1</a></li> <li id="end"><a href="javascript:void(0);">메뉴_5_2</a></li> </ul> </li> </ul> </li> <li id="end"> <em></em><a href="javascript:void(0);">메뉴_3_2</a> <ul> <li> <em></em><a href="javascript:void(0);">메뉴_4_1</a> <ul> <li><a href="javascript:void(0);">메뉴_5_1</a></li> <li id="end"><a href="javascript:void(0);">메뉴_5_2</a></li> </ul> </li> <li id="end"> <em></em><a href="javascript:void(0);">메뉴_4_2</a> <ul> <li><a href="javascript:void(0);">메뉴_5_1</a></li> <li id="end"><a href="javascript:void(0);">메뉴_5_2</a></li> </ul> </li> </ul> </li> </ul> </li> <li id="end"> <em></em><a href="javascript:void(0);">메뉴_2_2</a> <ul> <li> <em></em><a href="javascript:void(0);">메뉴_3_1</a> <ul> <li> <em></em><a href="javascript:void(0);">메뉴_4_1</a> <ul> <li><a href="javascript:void(0);">메뉴_5_1</a></li> <li id="end"><a href="javascript:void(0);">메뉴_5_2</a></li> </ul> </li> <li id="end"> <em></em><a href="javascript:void(0);">메뉴_4_2</a> <ul> <li><a href="javascript:void(0);">메뉴_5_1</a></li> <li id="end"><a href="javascript:void(0);">메뉴_5_2</a></li> </ul> </li> </ul> </li> <li id="end"> <em></em><a href="javascript:void(0);">메뉴_3_2</a> <ul> <li> <em></em><a href="javascript:void(0);">메뉴_4_1</a> <ul> <li><a href="javascript:void(0);">메뉴_5_1</a></li> <li id="end"><a href="javascript:void(0);">메뉴_5_2</a></li> </ul> </li> <li id="end"> <em></em><a href="javascript:void(0);">메뉴_4_2</a> <ul> <li><a href="javascript:void(0);">메뉴_5_1</a></li> <li id="end"><a href="javascript:void(0);">메뉴_5_2</a></li> </ul> </li> </ul> </li> </ul> </li> </ul> </li> </ul> </div> </textarea> <br><input onclick="runEx('runcode27253')" type="button" value="运行代码"><input onclick="doCopy('runcode27253')" type="button" value="复制代码"> <input onclick="doSave(runcode27253)" type="button" value="保存代码"> <a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">[Ctrl A 모두 선택 참고: </a>외부 J를 도입해야 하는 경우 실행하려면 새로 고쳐야 합니다 </div>]<script type="text/javascript"> (function(e){ for(var _obj=document.getElementById(e.id).getElementsByTagName(e.tag),i=-1,em;em=_obj[++i];){ em.onclick = function(){ //onmouseover var ul = this.nextSibling; if(!ul){return false;} ul = ul.nextSibling; if(!ul){return false;} if(e.tag != 'a'){ ul = ul.nextSibling; if(!ul){return false;} } //a 标签控制 隐藏或删除该行 for(var _li=this.parentNode.parentNode.childNodes,n=-1,li;li=_li[++n];){ if(li.tagName=="LI"){ for(var _ul=li.childNodes,t=-1,$ul;$ul=_ul[++t];){ switch($ul.tagName){ case "UL": $ul.className = $ul!=ul?"" : ul.className?"":"off"; break; case "EM": $ul.className = $ul!=this?"" : this.className?"":"off"; break; } } } } } } })({id:'menu',tag:'em'}); </script><br>온라인 데모 <a href="http://demo.jb51.net/js/2011/caidan/index.htm" target="_blank">http://demo.jb51.net/js/2011/caidan/index.htm</a>