Hi, I have a requirement where I need to hide the elements according to the active LI
suppose I have 10 LI elements when I reach to 5th position I need to show only 3rd - 7th elements, which means active - 2 and active +2 elements can be shown rest of them hides
how is this possible in Jquery

Deepak RawatPosted Jul 8, 2023, 12:54 PM
To hide elements based on the active list item (LI) position using jQuery, you can use the
.slice()and.hide()functions. Here's an example code snippet that demonstrates this:you have a
element containing the list items (). The code attaches a click event handler to each list item. When a list item is clicked, it calculates the start and end indices of the elements to show, based on the clicked item's index. Then, it hides all list items and shows only the elements within the specified range using the.slice()function.