try .parents() instead of .parent() if the parent you are looking for
is not the immediate parent of the element you specify (what Andy
said).

so $(this).parents("fieldset") should work

also, perhaps you should use .toggleClass

$(function(){
        $("a.toggle")
                .click(function(){
                   $
(this).parents("fieldset").toggleClass('collapsed')
                });

});

haven't tested this but seems ok

On Apr 4, 3:42 pm, noon <[EMAIL PROTECTED]> wrote:
> === jQuery code ===
> $(function(){
>         $("a.toggle")
>                 .click(function(){
>                         if ( $(this).parent("fieldset").hasClass("collapsed") 
> ) {
>                                 
> $(this).parent("fieldset").removeClass("collapsed");
>                         }
>                         else {
>                                 
> $(this).parent("fieldset").addClass("collapsed");
>                         }
>                 });
>
> });
>
> === HTML ===
>
> <fieldset class="collapsible collapsed group_5">
>         <legend>
>                 <a class="toggle" href="javascript:void(0)">Board Meeting
> Minutes and Resolutions</a>
>        </legend>
>         <div class="container oddRow">
>                 <div class="doc-date">02/13/2007</div>
>                 <div class="doc-title">Letter of Resignation - Vice President
> of Human Resources eff. 02/28/07</div>
>         </div>
> </fieldset>
>
> === Notes ===
> Doesn't error, but it sure doesn't do anything either.  Tried alerting
> some attributes like class or the typeof $(this).parent("fieldset")
> but kept coming up with undefined.  There isn't any other fieldset
> above that one.  I used to have the code -- if ($
> (this.parentNode.parentNode).hasClass("collapsed') -- and it worked.
> Can't determine what .parent() is doing for me here, besides
> frustrating.
>
> Appreciate any help or advice

Reply via email to