Whenever the number of rows in my dynamic table changes due to user events, all tr
elements that do not have the class .selected
are set to display:none;
. This means that at times, none of the table rows have the class selected
. The problem arises when I hide these rows using display:none
, because then the table header also disappears unless the initial first row is given the class selected
. What I want is for the table header to always stay visible, regardless of which rows are hidden or shown.
tr:not(.selected) {
display:none;
}
I attempted solutions like adding not(:first-child)
, but they did not work. Am I taking the right approach with this method? I thought that constantly adding and removing rows dynamically would be too labor-intensive or slow down the performance.