Hi Mitchell, I'm going to try writing some code and hopefully you'll get the
idea and make it work (as it's untested). Basically, instead of writing
everything out verbosely... try to determine automatically what needs to
happen from the information stored in the DOM.

$('.AccordionPanelContent a').click(function(){
    var targetId = this.id.toLowerCase();
    var txt = $(this).text();

    $("#attrname").css('background-color','#8FA9C5');
    $("#attrtext").text( txt );

    $( targetId ).show().siblings().hide();
});

I'm not sure about that last line... it depends on how many siblings. You
may consider rewriting it:

$( targetId ).show().siblings(':visible').hide();

Or, possibly:

$( targetId ).siblings(':visible').hide().end().show();

This page in the documentation is your friend:
http://docs.jquery.com/DOM/Traversing

Also, while I've coded this with your example/HTML in mind I really have to
say that I do not like having an id of "location" and an id of "Location"
... that's just screaming for trouble.

Cheers,
Brian.



On 8/2/07, Mitchell Waite <[EMAIL PROTECTED]> wrote:
>
>  That helps a lot Glen but I am still stuck.
>
>
>
> Here is my link
>
>
>
> http://www.whatbird.com/wwwroot/Components/Accordion%20Menu.html
>
>
>
> Each of the items inside a main menu will open its own layer, you can see
> the first two are working.
>
>
>
> And excuse my confusion I should have called this "*close all divs but one
> *" as it has nothing to do with "show all"
>
>
>
> I don't think :last applies to the last DIV  clicked.
>
>
>
> In a DIV can I use an ID and a class at the same time? Because if that was
> possible I could use addclass to hide all the divs with that class, then
> show the one that is clicked (assuming I could make the close all happen
> before the show)
>
>
>
> I'm not using any tables, and all I know is if an object is visible or
> invisible.
>
>
>
> Thanks
>
>
>
> Mitch
>
>
>
>
>
> *From:* jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] *On
> Behalf Of *Glen Lipka
> *Sent:* Thursday, August 02, 2007 7:30 PM
> *To:* jquery-en@googlegroups.com
> *Subject:* [jQuery] Re: Show all?
>
>
>
> Might be easier if you post an page that isn't working.  We could be more
> specific.
> However...
> Use a "class" when you want to refer to something that is repeated on the
> page.
> Also you can use :last to find the last one.
> $("tr:last").show() would show the last row found.
>
> Does that help?
>
> Glen
>
>  On 8/2/07, *Mitchell Waite* <[EMAIL PROTECTED]> wrote:
>
> What I am looking for is a way to hide the last one of these that was
> clicked. I tried saving the object that was last used in a var but that
> didnt work. I thought then maybe I could create some kind of "close all"
> that would close all the other layers but not the one we have clicked to
> show.
>
>            $('#Location').click(function() {
>          $("#attrname").css('background-color','#8FA9C5');
>          $("#attrtext").text("Location");
>          $("#location").show();
>          $("#shape").hide();
>    });
>
>        $('#Shape').click(function() {
>          $("#attrname").css('background-color','#8FA9C5')
>          $("#attrtext").text("Shape");
>          $("#location").hide();      /* should hide location */
>          $("#shape").show();
>    });
>
>
>

Reply via email to