Note: see this post if you'd like to make the Divi accordion tabs start closed by default.
Example of a Closable Accordion
The following example shows the feature in action. Click to open the accordion tabs and you'll then be able to close them again by clicking either on the toggle "close" icon, or on the toggle title itself.
How hot is the sun?
Is the moon really made of cheese?
Do you want closable Divi accordion toggles?
Making Accordions Closeable using Divi Booster
Divi Booster adds hundreds of new options to Divi, including the option to make accordions closeable. This can be applied to individual modules, or to all modules at once.
Making Individual Accordions Closeable using Divi Booster
Divi Booster adds an option to make individual accordions closeable into the Accordion Module settings. You'll find it at:
- Divi Booster 2.9.5 upwards: "Accordion Module Settings > Design > Toggle > Closeable"
- Divi Booster 2.8.4 – 2.9.4: "Accordion Module Settings > Design > Title Text > Closeable"

Making All Accordion Modules Closeable using Divi Booster
It is also possible to make all accordions on the site closeable using the option found under "Modules > Accordion" on the Divi Booster settings page. This option has been available since Divi Booster v1.9.9.

Make Accordion Modules Closeable using jQuery / CSS
If you don't have Divi Booster and are comfortable with adding jQuery / CSS code to Divi, you can make the accordions closable using the following method.
Step 1: Add the following jQuery code to your site, e.g. by pasting it into the "Divi > Theme Options > Integration > Add this code to the head of you blog" box.
1 <script> 2 jQuery(function($){ 3 $('.et_pb_toggle_title').click(function(){ 4 var $toggle = $(this).closest('.et_pb_toggle'); 5 if (!$toggle.hasClass('et_pb_accordion_toggling')) { 6 var $accordion = $toggle.closest('.et_pb_accordion'); 7 if ($toggle.hasClass('et_pb_toggle_open')) { 8 $accordion.addClass('et_pb_accordion_toggling'); 9 $toggle.find('.et_pb_toggle_content').slideToggle(700, function() { 10 $toggle.removeClass('et_pb_toggle_open').addClass('et_pb_toggle_close'); 11 12 }); 13 } 14 setTimeout(function(){ 15 $accordion.removeClass('et_pb_accordion_toggling'); 16 }, 750); 17 } 18 }); 19 }); 20 </script>
Related Post: Adding JavaScript / jQuery to Divi.
Step 2 (Optional): To add a "close" icon to the open toggles, add the following CSS code to your site, e.g. by pasting it into the "Divi > Theme Options > General > Custom CSS" box.
1 .et_pb_accordion .et_pb_toggle_open .et_pb_toggle_title:before { 2 display: block!important; 3 content: "\e04f" !important; 4 }
Related Post: Adding CSS to the Divi Theme
Styling the Close Icon
With any of the above methods of making accordions closeable, the close icon inherits the styles of the built in "open" icon. That means you can style both the open and close icons using the existing options in the accordion module settings, e.g.:

If you wish to apply certain styles to the close icon only (i.e. not to the open icon), then you can do so using CSS such as this:
1 /* Normal state */ 2 .et_pb_accordion .et_pb_toggle_open .et_pb_toggle_title:before { 3 color: grey !important; 4 } 5 6 /* Hover state */ 7 .et_pb_accordion .et_pb_toggle_open .et_pb_toggle_title:hover:before { 8 color: blue !important; 9 }
Related Post: Adding CSS to the Divi Theme
The example above will make the icon grey normally, changing to blue when hovered. If you aren't sure how to get the effect you want, just give me a shout in the comments.
Adding a Second Close Icon at the Bottom of Toggles
If your accordion toggles contain a lot of text, you may want to add a second close icon at the bottom to save your users having to scroll all the way back to the top of the text to close the toggle. Here's the code to do this. It should be used in addition to either the Divi Booster / manual methods given above. The code can be placed either in a code module on the page in question, or in the "Divi > Theme Options > Integrations > Add Code to the Head of your Blog" box.
1 <script> 2 jQuery(function($){ 3 $('.et_pb_toggle_title').each(function(){ 4 var $title = $(this); 5 var $closebar = $title.clone(true).addClass('db_pb_toggle_close2').html(' '); 6 $title.closest('.et_pb_toggle').append($closebar); 7 }); 8 9 $('.db_pb_toggle_close2').click(function(){ // Listen for clicks on the close bar 10 var $toggle = $(this).closest('.et_pb_toggle'); 11 var mainAreaOffset = $('#et-main-area').length ? $('#et-main-area').offset().top : 0; 12 $('html, body').animate({scrollTop: $toggle.offset().top - mainAreaOffset - 16}, 700); // Scroll considering the main area's top offset 13 }); 14 }); 15 </script> 16 <style> 17 .et_pb_toggle_close .db_pb_toggle_close2 { 18 display: none; 19 } 20 .db_pb_toggle_close2 { 21 margin-top: 10px; 22 visibility: hidden; 23 } 24 .db_pb_toggle_close2:before { 25 visibility: visible; 26 } 27 </style>
Please disregard my previous comment. Resolved. Thank you!
I used the code you provided on a Divi 3 site. It worked perfectly except there is no minus sign to click on. Any idea how to fix that? URL: spiritualityexplained.com/about.
Hi Byron, my apologies – it looks like the CSS code needed to display the minus sign somehow went missing from the post. I've added the code to the post above. Hope that helps.
That worked perfectly. Thank you!
it don´t work… :(
Hi Rafo, any chance you can provide a link to the page / post you're adding it on so that I can take a look?
Hi Dan,
I love your side, I already learned a lot. And I appreciate how much work do you do. I use the jQuery code and it works like a charme. But I do not have the minus to close the accordion. It can be closed, if you find the right spot, but I would like to have this spot marked :-)
Greetings from Germany
Claudia
Hi Claudia – there was supposed to be some additional CSS in the post for adding the minus icon, but it disappeared from the post for some reason…! I've added it back in. If you add the CSS to your site (no need to adjust the jQuery), it should start showing the icon.
oops submitted question too quickly :-(
Please use this instead
Hi Naive question. I’ve added your code snippet to Divi and my accordions are opening and closing beautifully. Thank you 🙂
However, I do not see the minus symbol to signal the close functionality to users. Where is this symbol assigned? Can I add it myself?
Thanks!
Hi Paul, I've updated the post to include the CSS needed to show the minus symbol – no need to modify the jQuery. I hope that helps.
Hi, thank you for the tips. This doesn't seem to work for me. Is it compatible with Divi 3?
Dan, sorry, I figured it out. I forgot to place within script tags. Thanks!!
Great, I'm glad you were able to figure it out ;)
THANK YOU DAN! I appreciate the jquery assist. Works perfectly!
Hey.
I'm using BOoster 2.3.1 and Divi 2.7.10, but the options
Make accordions start fully closed by default
Make accordions closable
has no effect.
The first acc is open and can't closed.
http://c6.vipdev.de/mehr-informationen/
Sorry Mario, I'm too late getting to this and I see you've taken down the page. If you're still trying to get this to work, please let me know. Cheers.
Dan,
This works, thanks! But how does the user know the accordion can be closed? There's no minus symbol or any logo to indicate that the accordion item can be closed. Am I missing something?
James
Hi James, I've just updated the post (and Divi Booster) with code to add a minus symbol to open accordion tabs. Hope that helps :)
The jQuery above doesn't seem to be working anymore.
Hi Ryan, I've just checked and the code is working for me on the latest version of Divi (2.7.8). Are you able to share a link to the page you're trying to use it on? Perhaps something else, such as a JavaScript error elsewhere on the page, is preventing it from working.
Hi. I wondering that it is possible to add a minus circle element (like the plus circle element that appear when the accordion is close) when the accordion get expanded. In this way, people will know that if they touch the minus element, the accordion will get close again.
Hi Nicolas, the CSS I've just added to the post will add a minus circle element. Hope it helps.
Hi Dan –
I'm having the same issue. The open/close feature is working, but there is no "-" icon appearing, so users wouldn't know to click. Will probably buy the plugin, anyway, but it's sort of the principle of the thing now and I'm just curious to know what I'm doing wrong….
Hi Matt – it was my mistake. I thought I had added the CSS code to the post, but it seems like it went astray somehow. I've updated the post now. If you add the CSS to your site, the icon should show up. Just leave the jQuery as it is.
Hi, Thanks for this code.
I want to share my code for adding the close icon.
I added somme CSS in my child theme.
.et_pb_toggle_open:before {
position: absolute;
right: 20px;
font-family: "ETmodules";
font-size: 16px;
color: #ccc;
content: "\e04f";
}
Thanks for sharing Max! I posted my own variant before I saw this. Hopefully one or the other works for everyone. Cheers! :)
Is it possible to have a "-" sign after the section is expanded? It shows the plus sign to expand it, but unless someone by chance runs their mouse over that area they will have no way to know the section can be closed that way. Thanks
Hi Jay, I've added CSS to the post above, which will display the "-" sign on open sections. Hope that helps.