Prototype $$() counting hidden rows

I’m using the Scriptaculous fade() function to remove a table row. It works fine and just after I call a function that uses $$(‘tbody tr’).each to iterate through each row in order to reset an alternating background.

What I’ve noticed is that the $$() iterates through even removed rows as if they’re still there. Is this the typical behavior or is it a timing issue with when the fade() or remove() finishes? How do I avoid the counting of removed rows, as it’s throwing off my alternating backgrounds.

The Fade effect doesn’t remove elements from the document but sets it its display value to none.

you’d want to use the Prototype method remove() to actually remove the elements.

if you are just hiding and showing, you potentially could set a className ‘inactive’ and check for that.