Only one accordion block open at a time Resolved Requested: 3 years and 4 months ago Hi, Is it possible to hide one item’s children once another is clicked? So that the accordion doesn’t get too big if the user clicks a lot of the parent items? Thanks in advance!
OnPoint Plugins 3 years and 4 months ago Hi Ricardo, Closing one section of the accordion when another is opened is possible by tapping into this plugin’s existing functionality. This may be accomplish with a little custom JavaScript: ( function( $ ) { setTimeout( function() { $( '.child-sidebar-menu > .has_children' ).click( '> span', function() { var parent = $( this ); $( '.child-sidebar-menu > .has_children.open' ).each( function() { if ( parent.text() !== $( this ).text() ) { asm_pro.accordion._expand_sub_menu( $( this ), $( this ).find( '> span' ) ); } } ); } ); }, 1000 ); } )( jQuery ); One way to put this on your site is to add the following action to your active theme’s functions.php file: add_action( 'wp_print_footer_scripts', function () { ?> <script> ( function( $ ) { setTimeout( function() { $( '.child-sidebar-menu > .has_children' ).click( '> span', function() { var parent = $( this ); $( '.child-sidebar-menu > .has_children.open' ).each( function() { if ( parent.text() !== $( this ).text() ) { asm_pro.accordion._expand_sub_menu( $( this ), $( this ).find( '> span' ) ); } } ); } ); }, 1000 ); } )( jQuery ); </script> <?php } ); Note: This version of the custom JavaScript will only target the first level child accordions. Have a great night! Mat Lipe
geral 3 years and 4 months ago Hi Mat! It works perfectly 😀 Thank you so much for your help and quick response! Kind regards, Carina
Hi Ricardo,
Closing one section of the accordion when another is opened is possible by tapping into this plugin’s existing functionality.
This may be accomplish with a little custom JavaScript:
One way to put this on your site is to add the following action to your active theme’s functions.php file:
Note: This version of the custom JavaScript will only target the first level child accordions.
Have a great night!
Mat Lipe
Hi Mat!
It works perfectly 😀
Thank you so much for your help and quick response!
Kind regards,
Carina