How to make Divi Toggle Accordians Closeable and start closed?
How to make Divi Toggle Accordians start closed:
add this code to Divi > Theme Options > Integrations > Header code
<!– Start Accordians Closed –>
<script>
jQuery(function($){
$(‘.et_pb_accordion .et_pb_toggle_open’).addClass(‘et_pb_toggle_close’).removeClass(‘et_pb_toggle_open’);
$(‘.et_pb_accordion .et_pb_toggle’).click(function() {
$this = $(this);
setTimeout(function(){
$this.closest(‘.et_pb_accordion’).removeClass(‘et_pb_accordion_toggling’);
},700);
});
});
</script>
copied from here: https://www.markhendriksen.com/how-to-make-the-divi-accordion-closed/
How to make Divi Toggle Accordians closeable:
add this code to Divi > Theme Options > Integrations > Header code
<script> jQuery(function($){ $(‘.et_pb_toggle_title’).click(function(){ var $toggle = $(this).closest(‘.et_pb_toggle’); if (!$toggle.hasClass(‘et_pb_accordion_toggling’)) { var $accordion = $toggle.closest(‘.et_pb_accordion’); if ($toggle.hasClass(‘et_pb_toggle_open’)) { $accordion.addClass(‘et_pb_accordion_toggling’); $toggle.find(‘.et_pb_toggle_content’).slideToggle(700, function() { $toggle.removeClass(‘et_pb_toggle_open’).addClass(‘et_pb_toggle_close’); }); } setTimeout(function(){ $accordion.removeClass(‘et_pb_accordion_toggling’); }, 750); } }); }); </script>
and add this to your child theme stylesheet
.et_pb_toggle_open .et_pb_toggle_title:before { display: block ; content: “\e04f”; }
copied from here: https://divibooster.com/make-divi-accordion-module-closable/
though i had to edit the stylesheet to move the close icon/button over the original minus icon:
/* *** closeable accoridians */
.et_pb_toggle_open .et_pb_toggle_title:before {
display: block !important;
content: “\e04f”;
color: #f5dd31 !important;
right: 14px !important;
}
