jQuery Toggle Help
- by Cameron
I have the following code:
$(document).ready(function() {
// Manage sidebar category display
jQuery("#categories > ul > li.cat-item").each(function(){
var item;
if ( jQuery(this).has("ul").length ) {
item = jQuery("<span class='plus'>+</span>").click(function(e){
jQuery(this)
.text( jQuery(this).text() === "+" ? "-" : "+" )
.parent().next().toggle();
return false;
});
jQuery(this).find(".children").hide();
} else {
item = jQuery("<span class='plus'> </span>");
}
jQuery(this).children("a").prepend( item );
});
});
This creates a sort of toggle system for my categories. But it will only work with 2 levels deep, what I need it to do is work with unlimited levels.