diff --git a/assets/js/script.js b/assets/js/script.js index cc8356a13..5e7bdc1d6 100644 --- a/assets/js/script.js +++ b/assets/js/script.js @@ -297,15 +297,29 @@ for (let i = 0; i < navigationLinks.length; i++) { } } +// function search_game() { +// let input = document.getElementById("searchbar").value; +// input = input.toLowerCase(); +// // let searchelement = document.getElementsByClassName("project-item active"); +// let searchelement = document.querySelectorAll(".project-item"); +// for (let i = 0; i < searchelement.length; i++) { +// if (!searchelement[i].innerHTML.toLowerCase().includes(input)) { +// searchelement[i].style.display = "none"; +// } else { +// searchelement[i].style.display = "list-item"; +// } +// } +// } + function search_game() { - let input = document.getElementById("searchbar").value; - input = input.toLowerCase(); - let searchelement = document.getElementsByClassName("project-item active"); + let input = document.getElementById("searchbar").value.toLowerCase(); + let searchelement = document.querySelectorAll(".project-item"); for (let i = 0; i < searchelement.length; i++) { - if (!searchelement[i].innerHTML.toLowerCase().includes(input)) { - searchelement[i].style.display = "none"; - } else { + let text = searchelement[i].innerText.toLowerCase(); + if (text.includes(input)) { searchelement[i].style.display = "list-item"; + } else { + searchelement[i].style.display = "none"; } } } diff --git a/index.html b/index.html index 87ec8e382..6817b7500 100644 --- a/index.html +++ b/index.html @@ -200,8 +200,8 @@