20 lines
563 B
JavaScript
20 lines
563 B
JavaScript
function searcher(){
|
|
let bar = document.getElementById("search");
|
|
let filter = bar.value.toUpperCase();
|
|
let posts = Array.from(document.getElementsByClassName("mb-3"));
|
|
let a, b, txtValue;
|
|
console.log(posts.length);
|
|
console.log(posts)
|
|
for (i=0; i < posts.length; i++){
|
|
a = posts[i].getElementsByTagName("h2")[0];
|
|
b = posts[i].getElementsByTagName("li")[3];
|
|
if(a.innerText.toUpperCase().indexOf(filter) > -1 || b.innerText.toUpperCase().indexOf(filter) > -1){
|
|
posts[i].style.display = "";
|
|
}
|
|
else {
|
|
posts[i].style.display = "none";
|
|
}
|
|
|
|
}
|
|
}
|