Looking for some guidance on setting up a mobile version of my product image with hover features. Currently using tooltips on desktop and planning to use a modified accordion on mobile, but struggling to make progress.
Customized some JS to toggle an accordion with "buttons" in separate divs. The buttons are functioning properly on mobile, but the panels don't hide when clicking another button. Need advice on resolving this issue.
Make sure to test it in a mobile window. Here's the updated code:
UPDATE: Fixed a formatting bug in the test code and added comments to JS and HTML.
SOLVED: Found a solution by reorganizing the HTML so that all panels are children of the same div. Used JavaScript to hide siblings and show the targeted element upon click.
if (document.documentElement.clientWidth < 1024) {
jQuery(document).ready(function($) {
$(".ul.one").click(function() {
$("#panel-1").show();
$("#panel-1")
.siblings()
.hide();
});