I have an element, that has class MuiTable-root jss51 jss52 jss53
.
Another element has class MuiTable-root jss51
.
Numbers after jss
can be different, but the number after the first jss
in the first element and the only jss
in the second element are the same. (eg. MuiTable-root jss23 jss24 jss25
for the first element and MuiTable-root jss23
for the second)
How do I select just the first element using css?
Edit:
Html I work with:
<div>
<table class="MuiTable-root jss51 jss52 jss53">
<colgroup>...</colgroup>
<thead class="MuiTableHead-root">...</thead>
</table>
<table class="MuiTable-root jss51">
<colgroup>...</colgroup>
<tbody class="MuiTableBody-root">...</thead>
</table>
</div>
I only need to change the instance of first table. I cannnot access <div>
above the tables. I need to work purely using tables’ classes. Again, number after jss
are not always 51, 52, 53
2
Answers
use this selector:
An explanation of this selector, here
Browser support – check here
If it is given that:
jss
in the first<table>
comes right after a class name that ends with a number between 0 and 9 (e.g.jss51 jss52
)jss
in the second<table>
does not come right after a class name that ends with a number between 0 and 9You can check for a
jss
occurence, that comes right after a numberY
between 0 and 9 withsee w3 documentation for reference:
For example: