I would like to be able to open a series of accordion items using a series of v2 buttons, and to ensure that when one accordion is opened, the others collapse. At the moment, when I assign a class, open_accordion, to each of the buttons, and specify a particular accordion id, e.g. #accordion1, #accordion2, etc. to each button, all accordion open when one of buttons is clicked. This is the js code I am using:
jQuery(function($) {
$(’.x-anchor-button.close_accordion’).on(‘touchend click’, function() {
$(’.x-acc-header’).removeClass(‘x-active’);
$(’.x-acc-item div[role=“tabpanel”]’).addClass(‘x-collapsed’);
});
$(’.x-anchor-button.open_accordion’).on(‘touchend click’, function() {
$(’.x-acc-header’).addClass(‘x-active’);
$(’.x-acc-item div[role=“tabpanel”]’).removeClass(‘x-collapsed’);
});
});
Grateful for your help, please.


