<div class="card">
<div class="card-header">
<button id='expand-collapse' type="button" data-parent="#blocks" data-toggle="collapse" data-target=".block" aria-expanded="false" aria-controls=".block">
</button>
</div>
<div class="card-block">
<div id="blocks">
<div class="list-group">
<div class="list-group-item">
<a data-toggle="collapse" href="#block-1" aria-expanded="false" aria-controls="block-1"></a>
<div class="collapse block" id="block-1">
<!--FIRST BLOCK BLOCK-->
</div>
</div>
<div class="list-group-item">
<a data-toggle="collapse" href="#block-2" aria-expanded="false" aria-controls="block-2"></a>
<div class="collapse block" id="block-2">
<!--SECOND BLOCK-->
</div>
</div>
<div class="list-group-item">
<a data-toggle="collapse" href="#block-3" aria-expanded="false" aria-controls="block-3"></a>
<div class="collapse block" id="block-3">
<!--THIRD BLOCK-->
</div>
</div>
</div>
</div>
</div>
</div>
$(function () {
$('#expand-collapse').on('click',function(){
$('button[data-toggle="collapse"]').each(function(){
var objectID=$(this).attr('data-target');
if($(objectID).hasClass('.collapse')===false)
{
$(objectID).collapse('show');
}
});
});
});
$(function () {
$('#expand-collapse').on('click',function(){
var allCollapsed = true;
$('button[data-toggle="collapse"]').each(function(){
var objectID=$(this).attr('data-target');
if($(objectID).hasClass('.collapse')===false)
{
allCollapsed = false;
}
});
$('button[data-toggle="collapse"]').each(function(){
if (allCollapsed) {
$(objectID).collapse('show');
} else {
$(objectID).collapse('hide');
}
});
});
});
$(function () {
$('#expand-collapse').on('click',function(){
var allExpanded = true;
$('button[data-toggle="collapse"]').each(function(){
var objectID=$(this).attr('data-target');
if($(objectID).hasClass('.collapse')===true)
{
allExpanded = false;
}
});
$('button[data-toggle="collapse"]').each(function(){
if (allExpanded) {
$(objectID).collapse('hide');
} else {
$(objectID).collapse('show');
}
});
});
});