Accordion Open All

Hi. Im tying to create a button that will open all accordion items at once. Like a collapse and expand all. But when im doing it via javascript like adding class cc-accordion-active it shows all but something weird happens when i clicked on individual accordion, it behaves like it is closed initially. so i need to click twice in order to close the single accordion. Is this possible in cwicly?

Hello @kris,

The open/close logic holds a bit more than adding the active class.
You might want to trigger a click() on all the targeted accordions instead.

In your click event listener, you can use the following:

// data-accordion is an attribute I've added to every accordion, in this case targeting with value grouped
const accordions = document.querySelectorAll(
  '[data-accordion="grouped"] [data-cc-accordion-header]'

accordions.forEach((accordion) => {

If you need more info, please don’t hesitate.