Adding 'active' class to open Bootstrap accordion item - 7-Views
Adding ‘active’ class to open Bootstrap accordion item
![](https://7-views.com/wp-content/uploads/2018/08/kisspng-web-development-html-css3-the-ohana-code-logo-2cpaper-projection-shaded_1660937-html-dropdown-js-5aebd5634bb501.0344507315254050273101-e1535005847318.png)
Several times we want to have our own custom class on open tab of our bootstrap acoordion so that you can apply your custom css to it.
A basic jQuery solution to add an ‘active’ class to the accordion heading of the currently active accordion item.
(function ($) { $(function () { $('.panel-collapse').on('show.bs.collapse', function () { $(this).siblings('.panel-heading').addClass('activelink'); }); $('.panel-collapse').on('hide.bs.collapse', function () { $(this).siblings('.panel-heading').removeClass('activelink'); }); }); })(jQuery);