I have many table, want to set css style on first row of the table on case first row has rowspan.
Name
Solution 1:
You can set it in Javascript background using:
nth-child(-n+${rowspan})
Eg.
let tr = document.getElementsByTagName("tr")[0];
let td = tr.getElementsByTagName("td")[0];
let rowspan = td.rowSpan? td.rowSpan:1;
var nodes = document.querySelectorAll(`tbody tr:nth-child(-n+${rowspan})`);
for (let i = 0; i < nodes.length; i++) {
nodes[i].style.background = '#1DA6C0';
}
I don't think this is possible with CSS.
You have to dynamically add the styles to the cells depending on the row-span.
Here I am assuming that you can have row-span only on the 1st cell of tbody.
Post a Comment for "Set Css Style On First Row Of The Table On Case First Row Has Rowspan"