-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgames.js
24 lines (19 loc) · 941 Bytes
/
games.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
function search_game() {
let input = document.getElementById('searchbar').value.toLowerCase();
// Select the container with the class "game-container"
let gameContainer = document.getElementsByClassName('games')[0];
// Select all elements within the container
let allElements = gameContainer.getElementsByTagName('*');
for (let i = 0; i < allElements.length; i++) {
let element = allElements[i];
let elementText = element.textContent.toLowerCase();
// Check if the element has the class "dontsearch"
let hasDontSearchClass = element.classList.contains('dontsearch');
// Check if the element text includes the search input and doesn't have the class "dontsearch"
if (!elementText.includes(input) || hasDontSearchClass) {
element.style.display = "none";
} else {
element.style.display = "list-item";
}
}
}