From 9ccba223803438427319db5cdacfb8073fd0fa91 Mon Sep 17 00:00:00 2001 From: vivi29 Date: Thu, 24 Oct 2024 14:10:09 +0530 Subject: [PATCH] Added case-insensitive search functionality for filtering cards based on user input. --- script.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/script.js b/script.js index 04553379..acb2b7a4 100644 --- a/script.js +++ b/script.js @@ -349,17 +349,14 @@ function toggleSidebar() { } function performSearch() { - let searchTerm = document.getElementById("search-input").value.toLowerCase(); - console.log(searchTerm); + let searchTerm = document.getElementById("search-input").value; let cards = document.querySelectorAll(".row"); cards.forEach(function (card) { - let cardHeading = card - .querySelector(".card-heading") - .innerText.toLowerCase(); + let cardHeading = card.querySelector(".card-heading").innerText; - // Check if the search term is in the card heading or description - if (cardHeading.includes(searchTerm)) { + // Perform case-insensitive comparison + if (cardHeading.toLowerCase().includes(searchTerm.toLowerCase())) { card.style.display = "block"; // Show the card } else { card.style.display = "none"; // Hide the card