I am currently utilizing Bootstraps collapse (accordion) feature and I want to modify the background color of the .panel-header
when it is open. My current code snippet is close, but I have encountered an issue.
$('.panel-group').on('show.bs.collapse', function () {
$(this).find('.panel-heading').addClass('active-panel');
});
$('.panel-group').on('hide.bs.collapse', function () {
$(this).find('.panel-heading').removeClass('active-panel');
});
The challenge lies in the fact that the .panel-group
(refer to documentation link above for structure) is the parent element of all .panel-heading
s, resulting in all panels receiving the .active-panel
class. How can I target only the panel heading that was clicked?