In this tutorial I'm going to show you how to open your Elementor Toggles or Accordions by default. You will be able to select specifically which toggles you want opened by default, and which toggles should stay closed.
For example, you can open toggle 1, 3 and 5, as seen in this example:
Please note that with the accordion element, you can only open one at a time. This tutorial will help you open a different one than the first. It won't open more than one.
Let's get started!
I have several other accordion, toggle and tabs related tutorials that might interest you:
Elementor Open Tabs On Hover Instead of Click
Elementor Open Specific Tab, Toggle or Accordion on Link Click
First, copy paste this Elementor toggle opened by default code
Add an HTML element on the same page as your toggle element, and add this code in it.
<script> /* Please login to get the code * The code will be for the Elementor Toggle & Accordion Open Those You Want On Load tutorial * Found at this URL https://element.how/elementor-toggle-open-by-default/ */ </script>
Edit the code to add the Elementor toggles you want to be opened by default
In the code, you will see this line:
let opened = [1, 3, 5];
This means that toggle 1, 3 and 5 will be opened by default.
If you want toggle 1 only to be opened on page load, you would use this:
let opened = [1];
And if you want toggle 2 and 6, this:
let opened = [2, 6];
Now, add the class name to your Elementor toggle element
Go to your toggle element, and under Advanced > CSS Classes, give it this class name:
<script> /* Please login to get the code * The code will be for the Elementor Toggle & Accordion Open Those You Want On Load tutorial * Found at this URL https://element.how/elementor-toggle-open-by-default/ */ </script>
Finally, enjoy your Elementor toggle opening by default!
Yep, it's that simple with the proper code.
Cheers!
4 Responses
I'm trying this out but it's only opening the last accordion in the array.
I'm using Elementor Pro 3.15.1
Hey Morgan!
Got a URL to share so that I could have a look?
Hello Maxime,
Do you think it is possible to adapt for tabs instead of accordion ?
Thanks you in advance
Olivier
Don't bother I did manage to do it myself adapting your code. Thanks !