-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearchMenu.html
139 lines (130 loc) · 4.04 KB
/
searchMenu.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search Menu</title>
<!-- <style>
*{
margin: 0;padding: 0;
font-family: sans-serif;
}
#mySearch{
width: 100%;
font-size: 17px;
padding: 11px;
border: 1px solid #ddd;
}
#myMenu{
list-style-type: none;
padding: 0;
margin: 0;
}
#myMenu li a{
text-decoration: none;
color: black;
padding: 12px;
display: block;
}
#myMenu li a:hover{
background-color: #eee;
}
</style> -->
<style>
*{
margin: 0;padding: 0;
font-family: poppins;
}
#mySearch{
font-size: 17px;
padding: 11px;
width: 100%;
border: 1px solid grey;
border-bottom: none;
outline: none;
}
#myMenu{
padding: 10px;
border: 1px solid grey;
border-top: none;
background-color: whitesmoke;
}
#myMenu li a{
text-decoration: none;
display: block;
font-size: 15px;
padding: 5px;
color: black;
}
#myMenu li a:hover{
background-color: #eee;
}
</style>
</head>
<body>
<!-- <input type="text" id="mySearch" onkeyup="myFunction()" placeholder="Search..." title="Type in a category">
<ul id="myMenu">
<li><a href="#">HTML</a></li>
<li><a href="#">CSS</a></li>
<li><a href="#">JavaScript</a></li>
<li><a href="#">PHP</a></li>
<li><a href="#">Python</a></li>
<li><a href="#">jQuery</a></li>
<li><a href="#">SQL</a></li>
<li><a href="#">Bootstrap</a></li>
<li><a href="#">Node.js</a></li>
</ul>
<script>
function myFunction(){
//Declare variables
var input,filter,ul,li,a,i;
input= document.getElementById("mySearch");
filter= input.value.toUpperCase();
ul= document.getElementById("myMenu");
li= ul.getElementsByTagName("li");
//Loop through all list items, and hide those who don't match the search query
for(i=0;i<li.length;i++){
a= li[i].getElementsByTagName("a")[0];
if(a.innerHTML.toUpperCase().indexOf(filter)>-1){
li[i].style.display= "";
}else{
li[i].style.display= "none";
}
}
}
</script> -->
<input type="text" id="mySearch" placeholder="Search..." title="Type in a cateogory" onkeyup="myFunction()">
<ul id="myMenu">
<li><a href="#">HTML</a></li>
<li><a href="#">CSS</a></li>
<li><a href="#">JavaScript</a></li>
<li><a href="#">jQuery</a></li>
<li><a href="#">Bootstrap</a></li>
<li><a href="#">C language</a></li>
<li><a href="#">Python</a></li>
<li><a href="#">XML</a></li>
<li><a href="#">React</a></li>
</ul>
<script>
function myFunction(){
//Declare all variables
var input,filter,ul,li,a,i;
input= document.getElementById("mySearch");
filter= input.value.toUpperCase();
ul= document.getElementById("myMenu");
li= ul.getElementsByTagName("li");
//iterate through all the li items
for(i=0;i<li.length;i++){
a= li[i].getElementsByTagName("a")[0];
if(a.innerHTML.toUpperCase().indexOf(filter)>-1){
li[i].style.display= "";
}
else{
li[i].style.display= "none";
}
}
}
</script>
</body>
</html>