forked from jaswanthkumar005/jas005
-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.html
109 lines (79 loc) · 2.34 KB
/
menu.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html lang="en">
<title></title>
<head>
<script>
var menu={
"content main":"content",
"subber":{"content1":"sub1","content2":"sub2","content3":"sub3"},
"subber1":{"content1":"sub1","content2":"sub2","content3":"sub3"}
};
var menu2={
"content":"content of our main intro",
"subber":"jaswanth",
"sub1":"sub1 content",
"sub2":"sub2 content",
"sub3":"sub3 content",
"content main1":"content1",
"subber1":"jaswanth2"
};
function func(){
menuCreator();
}
function menuCreator(){
var ul= document.createElement("ul");
var li = document.createElement("li");
var str="";
var menuKeys= Object.keys(menu);
//console.log(menuKeys);
str+="<ul>"
for(var x of menuKeys){
//console.log( typeof menu[x]);
//console.log(x);
console.log( menu[x]);
if(typeof menu[x]=="object"){
subMenu= Object.keys(menu[x]);
//console.log( Object.values(menu[x])+"menu");
str+="<li id='"+x+"' onclick='myfunction(this)'>"+x+"</li>"
for(var y of subMenu){
str+="<ul>";
//console.log(menu[x][y]);
str+="<li id='"+menu[x][y]+"'class='hidder' onclick='myfunction(this)'>"+y+"</li>"
str+="</ul>"
}
}else{
str+="<li id='"+menu[x]+"' onclick='myfunction(this)'>"+x+"</li>"
//console.log(x);
}
}
str+="</ul>";
// console.log(str);
document.getElementById("appenderId").innerHTML=str;
}
function myfunction(elem){
console.log(elem.id);
document.getElementById("content_area").innerHTML= menu2[elem.id];
}
</script>
<style>
ul{list-style-type:none;}
#appenderId li {
list-style: none;
text-align: center;
background-color: #000000;
color:#fff;
margin-right: 30px;
width: 150px;
line-height: 60px;
border:solid 1px #fff;
}
#appenderId li ul{ display:none;}
#appenderId li ul:hover{ display:block;}
</style>
</head>
<body onload="func()">
<div id="appenderId" style="border:solid 1px green;top:0px;left:0px;float:left">
</div>
<div id="content_area" style="border:solid 1px red;border:solid 1px red;float:left;width:300px;height:500px;"></div>
</body>
</html>