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.

Reply via email to