Skip to main content
All CollectionsTroubleshooting and FAQsFrequently Asked QuestionsAccordion Module
How to Close All Accordion Module's Items Upon Initial Page Load
How to Close All Accordion Module's Items Upon Initial Page Load

Learn how to adjust the Accordion module settings so that all items remain collapsed upon initial page load.

Updated over a week ago

Creating a clean and organized user experience often involves controlling the default state of interactive elements on your website.

We will guide you through the process of configuring the Accordion Module in Divi to ensure that all items remain collapsed upon initial page load.

By default, the Divi Theme's Accordion Module will open the first Accordion when the Page loads. To ensure that all items remain collapsed upon initial page load, you can use two different methods:

  1. Use custom CSS and an empty Accordion Item

  2. Use custom JS code

Use custom CSS and an empty Accordion Item

  1. Open the Accordion module's settings by clicking on the Gear icon

  2. Add a new Accordion item by clicking on the Add New Accordion Item icon

  3. Drag the new item at the top

    Divi - Drag the new Accordion  items to the top

  4. Click on the Gear icon to open its settings

    Divi - Open Accordion Item's settings

  5. Remove its Title and Body Text

  6. Go to Advanced Tab → Custom CSS → Free Form CSS

  7. Add this CSS code

    selector {
    display: none;
    }

Note: You can add as many Accordion Items as you need. Keep the first item in the list without a title and body text, and ensure it has the above CSS code added to Advanced Tab Custom CSS Free Form CSS.

The result can be seen in the screenshot below:

Use custom JS code

  1. Open the Accordion module's settings by clicking on the Gear icon

  2. Go to Advanced Tab → CSS ID & Classes → CSS Class and set a CSS class for the entire Accordion module. You can use dt-closed-accordion

    Divi - Accordion module with custom CSS class

  3. Go to Divi → Theme Option → Integration tab → Header

  4. Add this JS code:

    <script>
    (function ($) {
    $(document).ready(function () {
    $('.et_pb_module.et_pb_accordion.dt-closed-accordion .et_pb_accordion_item.et_pb_toggle_open')
    .addClass('et_pb_toggle_close')
    .removeClass('et_pb_toggle_open');
    });
    })(jQuery)
    </script>

Pro Tip: If you want all the Accordion modules to have the first item always collapsed across your entire website, use this JS code instead:

<script>
(function ($) {
$(document).ready(function () {
$('.et_pb_module.et_pb_accordion .et_pb_accordion_item.et_pb_toggle_open')
.addClass('et_pb_toggle_close')
.removeClass('et_pb_toggle_open');
});
})(jQuery)
</script>

Note: This JS code doesn't use custom CSS classes and will apply to any instance of the Accordion module on your website.

Did this answer your question?