Accordion Body One to stay always open when manually close all bodies

31 Views Asked by At

I want my accordion to automatically open the first item body by manually closing the all bodies in accordion

$(document).ready(function(){
   
    $('#accordionExample').each(function(i){
        $(this).on("click" ,{value:i},function(event){
            var allCollapsed = true;
            $('.accordion-item').each(function() {
                if ($(this).find('.collapse').length > 0) {
                    allCollapsed = false;
                    return false;
                }                        
            });

            if(allCollapsed==true)
            {
                alert("ban");
            }
        }); 
    });
});
0

There are 0 best solutions below