forked from Suchitra-Sahoo/AgriLearnNetwork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blog.js
30 lines (22 loc) · 814 Bytes
/
blog.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
function search(){
let box=[...document.querySelectorAll(".fcard")]
let val=document.getElementById('input');
let filter=val.value.toUpperCase().trim();
console.log(filter)
console.log(box)
for(let i=0;i<box.length;i++){
let component=box[i];
let h2=component.querySelector('h2');
let componentName=h2.textContent|| h2.innerText;
console.log(componentName)
console.log((componentName.toUpperCase().indexOf(filter)))
if(componentName.toUpperCase().indexOf(filter)>-1){
console.log(`Showing card ${i}: ${componentName}`);
component.style.display="flex";
}
else{
console.log(`Hiding card ${i}: ${componentName}`);
component.style.display="none";
}
}
}