-
Notifications
You must be signed in to change notification settings - Fork 0
/
product.js
30 lines (24 loc) · 939 Bytes
/
product.js
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
var side = document.getElementById("sidenav");
var menu = document.getElementById("menuicon");
var closeicon = document.getElementById("closenav");
menu.addEventListener("click", function () {
side.style.right = 0;
});
closeicon.addEventListener("click", function () {
side.style.right = "-50%";
});
// search function
var productcontainer = document.getElementById("search-container");
var search = document.getElementById("search");
var productlist = productcontainer.querySelector("div");
search.addEventListener("keyup", function (event) {
var enteredvalue = event.target.value.toUpperCase();
for (count = 0; count < productlist.length; count = count + 1) {
var productname = productlist[count].querySelector("h1").textContent;
if (productname.toUpperCase().indexOf(enteredvalue) < 0) {
productlist[count].style.display = "none";
} else {
productlist[count].style.display = "block";
}
}
});