In the example below, I’m trying to figure out how to hide the fieldset if the text within the tags = Groups
<fieldset class=" collapsible">
<legend class="collapse-processed"><a href="#">Groups</a></legend>
I tried this, but, it winds up hiding all the fieldsets, not just this one…
$(this).find('legend').each( function() {
if($(this).text('Groups')) {
$(this).parent().hide();
}
});
Here’s your problem:
This just changes the text of every legend to be “Groups”. And returns a jQuery object (which will evaluate to true). You probably want something like,
If you can guarantee that the legends you wish to hide are the only ones containing the word “Groups”, then you could simplify this further:
…which will select only those fieldsets containing a legend element that in turn contains the character sequence “Groups”.