The problem lies with .parent().parent().parent() attempting to find
the TABLE - it doesn't, it finds the table's TBODY.

try this instead...

//hide the calendar tables, then show first
$("#calendar table").hide();
$("#calendar #month-oct").show();

$("#calendar th a").click(function(){
    // show next table based on anchor
    $(this.href.substring(this.href.indexOf("#"),
this.href.length)).show();

    // hide current table
    $(this).parents('table:first').hide(); // changed this

    //don't click through
    return false;
  });



On Oct 10, 12:11 pm, "Luc Pestille" <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I have a simple calendar that I'm building, where I need to swap between
> the months (yes I know there are calendar applications, but I need
> something simple and lightweight), where my HTML looks like this:
>
> ---
> <div id="calendar">
>
> <a name="month-oct"></a>
> <table id="month-oct">
> <tr>
> <th></th>
> <th colspan="5">October</th>
> <th><a href="#month-nov" class="next-month">Next</a></th>
> </tr>
> </table>
>
> <a name="month-nov"></a>
> <table id="month-nov">
> <tr>
> <th><a href="#month-oct" class="prev-month">Prev</a></th>
> <th colspan="5">November</th>
> <th><a href="#month-dec" class="next-month">Next</a></th>
> </tr>
> </table>
>
> </div>
> ---
>
> and my jQuery script looks like this:
>
> ---
> //hide the calendar tables, then show first
> $("#calendar table").hide();
> $("#calendar #month-oct").show();
>
> $("#calendar th a").click(function(){
> // show next table based on anchor
> $(this.href.substring(this.href.indexOf("#"), this.href.length)).show();
>
> // hide current table
> $(this).parent().parent().parent().hide();
>
> //don't click through
> return false;});
>
> ---
>
> Here's the problem - when I click on "Next" in the first table, the
> second table is displayed, and the first dissapears, but when I click on
> "Prev" in the second table, it dissapears, but the first one doesn't
> re-appear! Why would that happen? The function to show the next table is
> the same as the previous, so i can't see what would cause it to not
> show? Does hide() now remove the HTML from the code or something?  I can
> accurately target the previous table - if I replace hide() with a css()
> rule, it works OK.
>
> Any ideas?
>
> Luc Pestille
> Web Designer
> in2, Thames House, Mere Park, Dedmere Road, Marlow, Bucks, SL7 1PB
> tel: +44 (1628) 899700  |  fax: +44 (1628) 899701  |  email: [EMAIL 
> PROTECTED]  |  web:www.in2.co.uk
> This message (and any associated files) is intended only for the use of 
> jquery-en@googlegroups.com and may contain information that is confidential, 
> subject to copyright or constitutes a trade secret. If you are not 
> jquery-en@googlegroups.com you are hereby notified that any dissemination, 
> copying or distribution of this message, or files associated with this 
> message, is strictly prohibited. If you have received this message in error, 
> please notify us immediately by replying to the message and deleting it from 
> your computer. Messages sent to and from us may be monitored. Any views or 
> opinions presented are solely those of the author jquery-en@googlegroups.com 
> and do not necessarily represent those of the company.
>
>  in2logo_long.gif
> 10KViewDownload

Reply via email to