$('heading').click( function() {
// find any current active divs and hide and remove class
$(".active").each( function() {
$(this).hide();
$(this).removeClass( 'active' );
})
$(this).next(".content").slideToggle(500);
$(this).next(".content").addClass( "active" ); // not sure if you can do this but hopefully you get the idea
})