I have a table that can contain nested tables which renders inside a drawer.
The nested table is the same component, and i’m trying to create a css selector that will select the td
elements of rows of the root table and not of nested tables.
I have started with the following selector:
table.querySelectorAll(`tbody tr > td:nth-child(${index + 1})`)
It indeed selected the right td elements but from all the rows of all tables. I should note that the nested table is within a div that has [data-state="open"]
but it didn’t help me so far. The only way i’m thinking on how to determine a row from nested row is that it has 1 parent table element instead of 2.
Thanks
2
Answers
Modifid answer:
Select all existing TDs then filter those are not direct children of the root table:
Old answer which selects all TDs without filtering:
Use the
:not
selector