FYI, my if statement was actually doing exactly what it was supposed
to.  The bug was inside the body of the if (I didn't post that :-().

Long story short, I was confused.  Basically prev and next are smarter
than I thought they were :-).  For what it's worth, my updated code is
below.  Basically what's going on is that I've got header rows and
detail rows.  When I delete the detail row I check to see if it is the
last one for its header, and if so, delete the header.  I may still
yet be doing it the hard way, but at least it works in Firefox now.

Thanks Karl and ricardobeat for your help.

  if ($(theTr).prev("tr").is(".headerrow") &&
    ($(theTr).next("tr").is(".headerrow") || $(theTr).is("tr:last-
child")))
  {
    $(theTr).prev("tr").remove();
  }
  $(theTr).remove();


On Nov 20, 12:21 pm, ricardobeat <[email protected]> wrote:
> Would that be a <tbody> in the way? Try putting it there yourself,
> this should avoid the problem:
>
> <table cellspacing="0">
> <tbody>
>   <tr>
>     <td></td>
>   </tr>
>   <tr>
>     <td></td>
>   </tr>
> </tbody>
> </table>
>
> On Nov 19, 11:57 pm,go_dores<[email protected]> wrote:
>
>
>
> > First of all, I'm just getting started with jQuery so thanks in
> > advance for your patience.  I have a table that I am manipulating and
> > I need to remove a row under a certain condition.  I originally wrote
> > the test below:
>
> > if (theTr.previousSibling && theTr.previousSibling.className ==
> > "headerrow" &&
> >   (!theTr.nextSibling || theTr.nextSibling.className == "headerrow"))
>
> > In English, I have a tr element stored in the variable theTr.  I am
> > testing for the case where its previous and next siblings have a
> > certain CSS class.
>
> > This code works fine on IE and Safari, but does not work on Firefox.
> > It look like in Firefox the tr's have extra text node siblings in
> > between them.  What I would like to do to fix this is to find a jQuery
> > expression that will allow me to do this in a cleaner way.  So what I
> > need is an expression that will search backward for the first tr
> > sibling, and forward for the first tr sibling, skipping over the extra
> > gunk that seems to be there with Firefox.
>
> > Here was my last stab at this before I gave up and decided to ask for
> > help :-).  The problem with the code below is that it seems to be
> > looking at the immediate previous element and checking to see if it's
> > a tr, and of course that is false in Firefox.
>
> > if ($(theTr).prev("tr").is(".departmentrow") &&
> >   ($(theTr).next("tr").is(".departmentrow") || $(theTr).is("tr:last-
> > child")))
>
> > Long story short, what's the best way to do a search like this?  Any
> > pointers would be appreciated.- Hide quoted text -
>
> - Show quoted text -

Reply via email to