I have trouble about to make table <td>/<th>
selection cells.
When cell(s) selected background-color: rgba(51, 122, 183, 0.2) !important;
will use
But It will replace old background-color:
CSS style
<td class="bg1 bg2"></td>
So it's work on another layer tag like this
<tr class="bg1"> <td class="bg2"></td> </tr>
but I don't want like this because each td have different state(class) for my job
Like some EXAMPLE Here
//DON'T focus
var td = document.getElementsByTagName("TD");
for (i = 0; i < td.length; i++)
td[i].onclick = doSomething;
function doSomething() {
this.classList.toggle("clicked")
}
table,
tr,
td {
border: 1px solid gray;
}
td{
width: 100px;
text-align: center;
}
.x {
/* td status can't change */
/*NON select BG*/
background-color: lightcyan;
}
.y {
/* td status can't change */
/*NON select BG*/
background-color: salmon;
}
.clicked {
/*selected BG*/
border: 1px double #4887C7;
background-color: rgba(51, 122, 183, 0.2) !important;
}
<table>
<tr>
<td class="x clicked">a</td>
<td class="y">b</td>
</tr>
<tr>
<td class="y clicked">c</td>
<td class="x">d</td>
</tr>
</table>
<hr> WHAT I need to be - but i want class x,y into td
<table>
<tr class="x">
<td class="clicked">a</td>
<td>b</td>
</tr>
<tr class="y">
<td class="clicked">c</td>
<td>d</td>
</tr>
</table>
I just want two background-color:
that blend together not replace
Addition: I have tried filter:
don't work for white BG