Advertisement
Guest User

Untitled

a guest
Oct 17th, 2015
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var arr=[
  2. {title:"first",submenu:
  3. [{title:"ek"},{title:"do"},{title:"teen"}]},
  4. {title:"second"},
  5. {title:"third",submenu:
  6. [{title:"do"},{title:"pal"}]}
  7. ];
  8. var ul=document.createElement('ul');
  9. document.body.appendChild(ul);
  10. for(var i=0;i<arr.length;i++)
  11.   {var li=document.createElement('li');
  12.   li.innerHTML=arr[i].title;
  13.   ul.appendChild(li);
  14.    
  15.     if (arr[i].submenu)
  16.       {
  17.         var ul2=document.createElement('ul');
  18.         ul2.style.display="none";    
  19.            
  20.        
  21.         li.appendChild(ul2);
  22.         for(var j=0;j<arr[i].submenu.length;j++)
  23.      
  24.       {
  25.          var li2=document.createElement('li');
  26.        li2.innerHTML=arr[i].submenu[j].title;
  27.          ul2.appendChild(li2);
  28.         }
  29.         li.onmouseover=function(){
  30.         ul2.style.display="block";}
  31.       }
  32.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement