NonInventPurchasingSystem/CPRNIMS.WebApps/wwwroot/js/sideBarSearch.js
2026-01-20 07:44:30 +08:00

24 lines
700 B
JavaScript

$(document).ready(function () {
// Get the list items (nav items) to be filtered
var $navList = $(".nav-list li:not(.profile)");
var $searchBar = $(".nav-list li:first-child");
// Add an input event listener to the search input
$("#searchInput").on("input", function () {
var searchText = $(this).val().toLowerCase();
// Loop through each nav item and show/hide based on user input
$navList.each(function () {
var navText = $(this).find(".links_name").text().toLowerCase();
if (navText.indexOf(searchText) === -1) {
$(this).hide();
} else {
$(this).show();
}
});
// Always show the search bar
$searchBar.show();
});
});