I have a box with a headbar-div and a content-div and I created a script which can toggle the content-div with a slide effect. Normally the headbar-div has a background-color #ccc but when I toggle the content away the background-color of the headbar-div should be #FFF; And after that, if I let the content be shown again the background-color should change again to #ccc.
With my code the problem is that if I click again the background-color doesn't change back
Script
$( ".togglepanelcontent" ).click(function() {
var icon = $( this );
icon.closest( ".panelgroup" ).find( ".panelcontent" ).slideToggle();
icon.closest( ".panelgroup" ).find( ".panelheadbar" ).addClass("panelheadbar_m");
});
HTML
<div id="module" class="panelgroup">
<div class="panelheadbar">Title<div class="togglepanelcontent"><span>-</span></div></div>
<div id="pc" class="panelcontent ui-resizable">
Text
</div>
<br>
CSS
.togglepanelcontent {
float: right; cursor: pointer;
}
.panelheadbar {
padding: 5px;
font-weight: bold;
color: #000;
overflow: hidden;
height: auto;
cursor: move;
border-bottom: 1px solid #333;
background-color: #ccc;
}
.panelheadbar_m {
background-color: #FFF !important;
}
.panelheadbar_m:hover {
background-color: #ccc !important;
}
.panelcontent {
overflow: auto;
overflow-x: hidden;
padding: 10px;
top: 0px;
left: 0px;
background-color: #FFF;
border-left: 1px solid #333;
border-right: 1px solid #333;
border-bottom: 1px solid #333;
}
.addClass("panelheadbar_m")is missing