Shopify themes, liquid, logos, and UX
Hello everyone, I need a little help. On my Shopify store, when I open a filter, such as the price filter, and then open another filter like the color filter, the price filter remains open. I want the filters to work so that when I open one, the previously opened filter closes automatically. Is there a code to achieve this?
Any help would be greatly appreciated!
My store URL: https://myperfectwear.com/
add this script:
document.addEventListener('DOMContentLoaded', function() {
const detailsElements = document.querySelectorAll('details.accordion');
detailsElements.forEach(detail => {
detail.addEventListener('click', function() {
detailsElements.forEach(d => {
d.removeAttribute('open');
d.setAttribute('aria-expanded', 'false');
}
});
if (detail.hasAttribute('open')) {
detail.setAttribute('aria-expanded', 'true');
} else {
detail.setAttribute('aria-expanded', 'false');
}
});
});
});
Hello @Kyle_liu thanks for replying , I added my comment I will highly appreciate your response
Thank you so much @Kyle_liu . Where I should add this script ? Can you please tell me . 🙂
Hello
Thank you so much @Kyle_liu . Where should I add this script? Can you please tell me .
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024