Maybe this old jQuery code will help as a start? It works with unlimited “child nodes”.
$("<parent node selector here>").toggle(
function () {
$(this).css({"color":"#fff",
"background-image":"url(./includes/plus-8.png)",
"background-repeat": "no-repeat",
"line-height": "8px"});
$(this.childNodes).css({"display":"none"});
},
function () {
$(this).css({"color":"#000",
"background-image":"url(./includes/minus-8.png)",
"background-repeat": "no-repeat",
"line-height": "normal"});
$(this.childNodes).css({"display":"inline"});
}
);function init(){
$("#toggle_ctrl").text('<expand all button text here>');
$("#toggle_ctrl").css({"display":"block"});
$("#toggle_ctrl").toggle(
function(){
$("#toggle_ctrl").text('<close all button text here>');
$("<parent node selector here>").each( function() {
if ( $(this).css('line-height') == '8px' )
{
$(this).trigger('click');
}
});
$("<parent node selector here>").css({"color":"#000",
"background-image":"url(./includes/minus-8.png)",
"background-repeat": "no-repeat",
"line-height": "normal"});
},
function () {
$("#toggle_ctrl").text('<expand all button text here>');
$("<parent node selector here>").each( function() {
if ( $(this).css('line-height') == 'normal' )
{
$(this).trigger('click');
}
});
$("<parent node selector here>").css({"color":"#fff",
"background-image":"url(./includes/plus-8.png)",
"background-repeat": "no-repeat",
"line-height": "8px"});
}
);
$("<parent node selector here>").trigger('click');
}
$(document).ready(function() {
init();
});