How To Make Accordion Module Tabs Closable

How To Make Accordion Module Tabs Closable

Accordion 1
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
Accordion 2
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Add the following code to make Accordion close at startup.

<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>

Add the following code to make an open Accordion to close

<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>

Finally add the following CSS to add (Minus) icon after the Accordion title of an open Accordion

.et_pb_toggle_open .et_pb_toggle_title:before {
display: block !important;
content: “\e04f”;
}

How to Collapse/Show the Divi Mobile Menu

How to Collapse/Show the Divi Mobile Menu

Copy all codes and paste them here – Divi Theme Options > Integrations > Add code to the body.

<style type=”text/css”>
#main-header .et_mobile_menu .menu-item-has-children > a { background-color: transparent; position: relative; }
#main-header .et_mobile_menu .menu-item-has-children > a:after { font-family: ‘ETmodules’; text-align: center; speak: none; font-weight: normal; font-variant: normal; text-transform: none; -webkit-font-smoothing: antialiased; position: absolute; }
#main-header .et_mobile_menu .menu-item-has-children > a:after { font-size: 16px; content: ‘\4c’; top: 13px; right: 10px; }
#main-header .et_mobile_menu .menu-item-has-children.visible > a:after { content: ‘\4d’; }
#main-header .et_mobile_menu ul.sub-menu { display: none !important; visibility: hidden !important; transition: all 1.5s ease-in-out;}
#main-header .et_mobile_menu .visible > ul.sub-menu { display: block !important; visibility: visible !important; }
</style>

<script type=”text/javascript”>
(function($) {

function setup_collapsible_submenus() {
var $menu = $(‘#mobile_menu’),
top_level_link = ‘#mobile_menu .menu-item-has-children > a’;

$menu.find(‘a’).each(function() {
$(this).off(‘click’);

if ( $(this).is(top_level_link) ) {
$(this).attr(‘href’, ‘#’);
}

if ( ! $(this).siblings(‘.sub-menu’).length ) {
$(this).on(‘click’, function(event) {
$(this).parents(‘.mobile_nav’).trigger(‘click’);
});
} else {
$(this).on(‘click’, function(event) {
event.preventDefault();
$(this).parent().toggleClass(‘visible’);
});
}
});
}

$(window).load(function() {
setTimeout(function() {
setup_collapsible_submenus();
}, 700);
});

})(jQuery);
</script>

Results after adding codes.