-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathscroll.js
66 lines (58 loc) · 2.34 KB
/
scroll.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
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
let mybutton = document.getElementById("myBtn");
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}
var cartArr = JSON.parse(localStorage.getItem("cart-list")) || [];
console.log(document.querySelector(".cart-count"));
// search functionality
document.querySelector(".btn1").addEventListener("click",funsearch);
function funsearch(){
event.preventDefault();
var key=document.querySelector("#search").value;
key=key.toUpperCase();
if(key.includes("BEAUTY")){
window.open("beauty.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("CLOTH")){
window.open("clothe.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("FOOD")){
window.open("food.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("HEALTH")){
window.open("health.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("HOME")){
window.open("home.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("JWELLERY")){
window.open("jwellery.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("KIDS")){
window.open("kids.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("PET")){
window.open("pet.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("SHOES")){
window.open("shoes.html","_self");
document.querySelector("#search").value="";
}else if(key.includes("SPORTS")){
window.open("sports.html","_self");
document.querySelector("#search").value="";
}
}
// cart logo
var count = localStorage.getItem("cartcount") || 0;
document.querySelector(".cart-count").innerText = count;