Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var services={
- title:"Services",
- dropdown:["Buy","Sell","GTFO"]
- };
- var contacts={
- title:"Contacts",
- dropdown:["1","2","3","4"]
- };
- var aboutUs={
- title:"About us",
- dropdown:["3","4"]
- };
- var menu=[services, contacts, aboutUs];
- var ul = document.createElement("ul");
- document.body.appendChild(ul);
- for(i in menu){
- var li = document.createElement("li");
- ul.appendChild(li);
- li.innerHTML=menu[i].title;
- if(menu[i].dropdown != null && menu[i].dropdown.length!=0){
- var ul2 = document.createElement("ul");
- li.appendChild(ul2);
- ul2.style.display="none";
- for(j in menu[i].dropdown){
- var li2 = document.createElement("li");
- ul2.appendChild(li2);
- li2.innerHTML = menu[i].dropdown[j];
- };
- }
- };
- li.onmouseover=function(){
- ul2.style.display="block";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement