24 lines
700 B
JavaScript
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();
|
|
});
|
|
});
|