国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

javascript實現樹形菜單的方法

2024-05-06 16:23:19
字體:
來源:轉載
供稿:網友

這篇文章主要介紹了javascript實現樹形菜單的方法,涉及javascript動態操作頁面元素與節點屬性的相關技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了javascript實現樹形菜單的方法。分享給大家供大家參考。具體如下:

 

 
  1. var ME={ 
  2. ini:{i:true,d:{},d1:{},h:0,h1:0,h2:0}, 
  3. html:function(da,f){ 
  4. var s='<ul'+(f?' class="f"':'')+'>'
  5. for(var i=0,l=da.length;i<l;i++){ 
  6. if(typeof(da[i].pid)=='object'){ 
  7. 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>'
  8. this.ini.i=false
  9. s+=this.html(da[i].pid,(i+1==l)); 
  10. }else
  11. s+='<li><button type="button" class="'+(i+1==l?'e3':'e1')+'"></button><span><button type="button" class="m1"></button><a href="http://www.survivalescaperooms.com" target="mainFrame">'+da[i].ming+'</a></span>'
  12. s+='</li>'
  13. s+='</ul>'
  14. return s; 
  15. }, 
  16. st:function(id,da){ 
  17. document.getElementById(id).innerHTML=this.html(da); 
  18. }, 
  19. yc:function(a){ 
  20. var s=a.className.substr(1); 
  21. if(s%2){ 
  22. this.ini.d=a.parentNode.children[2]; 
  23. this.ini.h1=this.hei(this.ini.d); 
  24. this.ini.h3=this.ini.h1/10; 
  25. this.yc1(1); 
  26. a.className='s'+(parseInt(s)+1); 
  27. a.parentNode.children[1].children[0].className='r2'
  28. var ol=a.parentNode.parentNode._; 
  29. if(typeof(ol)=='object'){ 
  30. this.ini.d1=ol; 
  31. this.ini.h=ol.offsetHeight; 
  32. this.ini.h2=this.ini.h/10; 
  33. this.yc2(1); 
  34. ol.parentNode.children[0].className='s'+(parseInt(ol.parentNode.children[0].className.substr(1))-1); 
  35. ol.parentNode.children[1].children[0].className='r1'
  36. a.parentNode.parentNode._=a.parentNode.children[2]; 
  37. }else
  38. this.ini.d1=a.parentNode.children[2]; 
  39. this.ini.h=this.ini.d1.offsetHeight; 
  40. this.ini.h2=this.ini.h/10; 
  41. this.yc2(1); 
  42. a.className='s'+(parseInt(s)-1); 
  43. a.parentNode.children[1].children[0].className='r1'
  44. a.parentNode.parentNode._=''
  45. }, 
  46. yc1:function(b){ 
  47. var h1=ME.ini.h1-(11/(b+1)-1)*ME.ini.h3; 
  48. with(ME.ini.d.style){ 
  49. height=h1+'px'
  50. display='block'
  51. if(b<10){ 
  52. setTimeout('ME.yc1('+(b+1)+')',25); 
  53. }else
  54. ME.ini.d.style.display='block'
  55. ME.ini.d.style.height=''
  56. }, 
  57. yc2:function(b){ 
  58. var h1=(11/(b+1)-1)*ME.ini.h2; 
  59. with(ME.ini.d1.style){ 
  60. height=h1+'px'
  61. if(b<10){ 
  62. setTimeout('ME.yc2('+(b+1)+')',25); 
  63. }else
  64. ME.ini.d1.style.display=''
  65. ME.ini.d1.style.height=''
  66. }, 
  67. hei:function(a){ 
  68. var b=a.cloneNode(true); 
  69. b.style.position='absolute';  
  70. b.style.display='block';  
  71. b.style.visibility='hidden'
  72. a.parentNode.appendChild(b); 
  73. var h=b.offsetHeight; 
  74. a.parentNode.removeChild(b); 
  75. return h; 

希望本文所述對大家的javascript程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 隆子县| 西青区| 石林| 虞城县| 连云港市| 英山县| 泌阳县| 孟连| 达日县| 内黄县| 邛崃市| 灵寿县| 聂拉木县| 寿光市| 清河县| 梧州市| 海城市| 贵德县| 安西县| 泉州市| 嘉义市| 敖汉旗| 呼图壁县| 清水河县| 巫山县| 余江县| 揭阳市| 墨江| 太和县| 西乡县| 乐山市| 塔城市| 遵义市| 阿瓦提县| 吉安县| 高尔夫| 牡丹江市| 新和县| 三河市| 民乐县| 临高县|