-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (32 loc) · 1.09 KB
/
index.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
function toggleMobileMenu(menu) {
menu.classList.toggle('open');
}
//search bar
const searchBox = document.querySelector(".search-box");
const searchBtn = document.querySelector(".search-icon");
const cancelBtn = document.querySelector(".cancel-icon");
const searchInput = document.querySelector("input");
const searchData = document.querySelector(".search-data");
searchBtn.onclick =()=>{
searchBox.classList.add("active");
searchBtn.classList.add("active");
searchInput.classList.add("active");
cancelBtn.classList.add("active");
searchInput.focus();
if(searchInput.value != ""){
var values = searchInput.value;
searchData.classList.remove("active");
searchData.innerHTML = "in progress : You typed " + "<span style='font-weight: 500;'>" + values + "</span>";
}else{
searchData.textContent = "";
}
}
cancelBtn.onclick =()=>{
searchBox.classList.remove("active");
searchBtn.classList.remove("active");
searchInput.classList.remove("active");
cancelBtn.classList.remove("active");
searchData.classList.toggle("active");
searchInput.value = "";
}
// coded by Rankush