Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var arr=[
- {title:"first",submenu:
- [{title:"ek"},{title:"do"},{title:"teen"}]},
- {title:"second"},
- {title:"third",submenu:
- [{title:"do"},{title:"pal"}]}
- ];
- var ul=document.createElement('ul');
- document.body.appendChild(ul);
- for(var i=0;i<arr.length;i++)
- {var li=document.createElement('li');
- li.innerHTML=arr[i].title;
- ul.appendChild(li);
- if (arr[i].submenu)
- {
- var ul2=document.createElement('ul');
- ul2.style.display="none";
- li.appendChild(ul2);
- for(var j=0;j<arr[i].submenu.length;j++)
- {
- var li2=document.createElement('li');
- li2.innerHTML=arr[i].submenu[j].title;
- ul2.appendChild(li2);
- }
- li.onmouseover=function(){
- ul2.style.display="block";}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement