Hi,
I have created this design
The current way this is working is also not very UX-friendly. What I would like do to is to bring the “selected-items” to the top. Those items are in an array so I tried this …:
“`
function showMenuItems() {
for (let i = 0; i < menuItems.length; i++) {
menuItems[i].classList.remove(“selected-items”);
if (currentImg.dataset.food != menuItems[i].dataset.menu) {
menuItems[i].classList.add(“selected-items”);
menuItems.push(menuItems[0]);
}
if (currentImg.dataset.food == “bestsellers”) {
menuItems[i].classList.remove(“selected-items”);
}
}
}
also,
“`
function showMenuItems() {
for (let i = 0; i < menuItems.length; i++) {
menuItems[i].classList.remove(“selected-items”);
if (currentImg.dataset.food != menuItems[i].dataset.menu) {
menuItems[i].classList.add(“selected-items”);
menuItems.push(menuItems[0]);
}
if (currentImg.dataset.food == “bestsellers”) {
menuItems.push(menuItems[0]);
}
if (currentImg.dataset.food == “bestsellers”) {
menuItems[i].classList.remove(“selected-items”);
}
}
}
Both of which do not work and also after saving the browser crashes.
Do you have any ideas of what I could try?
**sorry for missing imgs