My dilemma involves a dropdown menu and a list of elements that are initially set to hidden using CSS. When an item is selected from the dropdown, it becomes visible. However, I am struggling with finding a way to revert the previously selected element back to hidden (display:none
) when a new one is chosen. Manually looping through each element seems inefficient, especially with a large number of items. Is there an elegant solution using jQuery or JavaScript to achieve this? You can find my current code in this JSFiddle link. Any help is appreciated!