1š
ā
Just as some conceptual support:
what you want is to loop through the descendants of a given element and based on a switch, add behavior, right?
You want to try something like:
- add classnames in appropriate places: ācollapse-stackā, ācollapse-labelā, ācollapse-listā (label & list might even be just ācollapsableā).
- have jQuery loop through these generic items.
like:
$(document).ready(function() {
$('.collapse-stack').each(function(){
//this = current collapse stack
$(this).click(function() {
if ( $(this).is(':checked') ) {
$(".collapse-label, .collapse-list").each(function(){
//this = current collapse-label
$(this).show();
});
}else{
$(".collapse-label, .collapse-list").each(function(){
//this = current collapse-label
$(this).hide();
});
}
});
})
});
or somesuch. Play around with that āeachā function.
š¤Multifarious
Source:stackexchange.com