Advertisement
Guest User

Untitled

a guest
Nov 14th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var services={
  2.     title:"Services",
  3.     dropdown:["Buy","Sell","GTFO"]
  4. };
  5. var contacts={
  6.     title:"Contacts",
  7.     dropdown:["1","2","3","4"]
  8.  
  9. };
  10. var aboutUs={
  11.     title:"About us",
  12.     dropdown:["3","4"]
  13. };
  14. var menu=[services, contacts, aboutUs];
  15.  
  16. var ul = document.createElement("ul");
  17. document.body.appendChild(ul);
  18.  
  19. for(i in menu){
  20.     var li = document.createElement("li");
  21.     ul.appendChild(li);
  22.     li.innerHTML=menu[i].title;
  23.  
  24.     if(menu[i].dropdown != null && menu[i].dropdown.length!=0){
  25.         var ul2 = document.createElement("ul");
  26.         li.appendChild(ul2);
  27.         ul2.style.display="none";
  28.        
  29.  
  30.         for(j in menu[i].dropdown){
  31.             var li2 = document.createElement("li");
  32.             ul2.appendChild(li2);
  33.             li2.innerHTML = menu[i].dropdown[j];
  34.         };
  35.     }
  36. };
  37. li.onmouseover=function(){
  38.     ul2.style.display="block";
  39.      }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement