forked from vikhyatsingh123/Naruto-Shippuden
-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchbar.js
40 lines (24 loc) · 846 Bytes
/
searchbar.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
const icon = document.querySelector('.icon');
const search = document.querySelector('.search');
icon.addEventListener('click',()=>{
search.classList.toggle('activated');
})
const search_box = document.querySelector('#mysearch');
search_box.addEventListener('input',()=>{
window.scrollTo(0, 1383.33);
const filter = search_box.value.toUpperCase();
let container = document.getElementById('cont');
let cont = container.getElementsByClassName('card')
for(let i=0;i<cont.length;i++)
{
const h = cont[i].getElementsByTagName('h2')[0];
const textValue = h.textContent.toUpperCase()
if(textValue.includes(filter))
{
cont[i].style.display = 'block'
}
else{
cont[i].style.display = 'none';
}
}
})