Search code examples
wordpresswordpress-gutenberggutenberg-blocks

Accordion from WP Plugin Advanced Gutenberg - Prevent to open first Accordion


I´m using the accordion from plugin "Advanced Gutenberg" for Wordpress. The plugin by default opens the first tab. But I want to show all tabs closed. So I wrote a little script that close the first accordion on document ready:

$('.ui-accordion-content').css({
    'display' : 'none',
});

That worked. So all accordions have display: none by default. But if I click to open the first accordion now, it opens only after the second click. All other accordions opens after the first click.

Do you have an idea what´s the issue is?


Solution

  • You can use following jQuery to get this done:

    $('.ui-accordion-header').first().click();
    

    Hope this helps!