Close accordion section


#1

Hi there,

I’m having a bit of an issue with the accordion.

I’m able to open and close accordion sections using ‘Multiple toggles open at a time’ option in the accordion settings. However, I’d like to have all accordions closed on initial page load so I’m forced to use ‘One toggle open at a time’ option (and fill -1 as initial index).

‘One toggle open at a time’ will not allow us to close the accordion sections once opened.

Can you help us fixing this?

Best regards


#2

Hello,

Please select “Multiple toggles open at a time” option and add this code in Theme Options > Advanced > Custom JS:

(function($){
var closeAccordion = function() {
     $('.mk-accordion').each(function(){
         $(this).find('.mk-accordion-single').removeClass('current');
         $(this).find('.mk-accordion-pane').hide();
     });
};
 
$(document).ready(closeAccordion);
$(window).load(closeAccordion);
})(jQuery);

Let us know the result.

Best regards,
Artbees Support.


#3

Hello,

Thanks for the suggested solution. This works great for desktop! However, on mobile site all toggles are open and not able to close. Do you have a solution for that too?

URL: http://birdgenetics.svotestserver.nl/veelgestelde-vragen/

Best regards


#4

Hi there,

For mobile the solution doesn’t work. All accordion section are open by default and not able to close.

Do you have a suggestion for this too?

Thank you in advance.

Best regards


#5

Hello,

What option did you set in “Mobile Friendly Accordions” field https://prnt.sc/i8121b ?
Did you enable it? If so, try to disable and check the page after that.

Best regards,
Artbees Support.


#6

Yes, I enabled it. After disabling it works. Thanks!


#7

Hello,

You’re welcome.

Best regards,
Artbees Support.