I am attempting to open/collapse sections of my site that are fieldsets with the click event on the legend tag. However I'm going to need to use a wrapInner to add a div inside the fieldset to hide the content...however this also hides the legend (which I definately dont want to do) :-). How can I use wrapInner but specify not to hide the legend (or alternatively the first element contained within the fieldset - as it will always be the legend).
$("#mainarea fieldset").wrapInner("<div class='fieldsetWrapper'></div>");
$("#mainarea fieldset:not(:first)").addClass("fsClosed"); // Close all fieldsets within the main area (but not the first one)
$("#mainarea fieldset legend").mousedown(function(){ // When clicking the legend of a fieldset ...
$("#mainarea fieldset:not(.fsClosed)").addClass("fsClosed"); // If it's already open, close it
$(this).parent().removeClass("fsClosed"); // If it's closed, remove the closed class from the containing fieldset
return false;
});
Cheers Mark