-2

How could i modify the code so that collapse panel is by default closed only on click it should open and again on click it should close. here is the code which I am using. The code makes Panel by default Open.

    $(document).on('click', '.btn-click', function(e){
    var $this = $(this);

if(!$this.hasClass('panel-collapsed')) {
        $this.parents('.panel').find('.panel-body').slideUp();
    $this.addClass('panel-collapsed');
    $this.find('i').removeClass('fa-chevron-circle-up').addClass('fa-chevron-circle-down');
} else {
    $this.parents('.panel').find('.panel-body').slideDown();
    $this.removeClass('panel-collapsed');
    $this.find('i').removeClass('fa-chevron-circle-down').addClass('fa-chevron-circle-up');
}
})
Robusto
  • 31,447
  • 8
  • 56
  • 77
Ravi
  • 140
  • 1
  • 12

1 Answers1

0

To have the panel closed by default, you should edit css attributes for initial display. For clicking event, you need custom toggle event with callbacks https://stackoverflow.com/a/4911660/1123532

Community
  • 1
  • 1
emrhzc
  • 1,347
  • 11
  • 19