Reputation: 83
How add active class on opened panel ? I open panel by hash.
$(document).ready(function () {
var id = window.location.hash;
$(id).trigger('click');
$("#accordion").find('id').addClass("in");
});
}
But now i need add active class on .panel-header . With click i did this
$('.panel-heading a').click(function() {
$(this).parents('.panel-header').addClass('active');
});
How add active class without user click ? On .panel-header to opened panel?
Here code with html JsFiddle
Upvotes: 0
Views: 288
Reputation: 1554
$(document).ready(function () {
var id = window.location.hash,
elem = $("#accordion").find('id');
$(id).trigger('click');
elem.addClass("in");
elem.parent().find('.panel-header').addClass('active');
});
Upvotes: 1