> $("#testtable tr").each(function(t){ That selector says to select any tr that is a descendant of #testtable. And it did! The tr in nested tables are descendants of the original table too, but they're not direct children. If you just want the tr elements in the outer table, try a selector like this:
#testtable > tbody > tr Even if you don't have a tbody in your markup it's implicit, but it's a good idea to put the tbody in there anyway.