Есть ли способ выбрать дочерний элемент таблицы первой таблицы с тем же именем класса, а затем выбрать 1-й элемент TD? - PullRequest
0 голосов
/ 20 сентября 2019

Я пытаюсь применить стиль к данным таблицы, но не могу получить правильный элемент, так как у них нет классов или идентификаторов.Таблицы имеют одинаковое имя класса, и я смог выделить правильную таблицу с помощью таблицы: nth-of-type (2).Я просто не могу понять, как правильно соединить селекторы, чтобы получить правильный элемент.

Самое последнее, что я попробовал, это

div # esri_dijit_Legend_0_BuckQuery таблица: nth-of-type (2)> tbody> tr> td: first-child

Нижеэто диаграмма HTML


<table class="className">
    <tbody>
        <tr>
            <td>  Need to apply style to this element only
            <td>
        </tr>
    </tbody>
</table>
<table class="className">
    <tbody>
        <tr>
            <td>  Don't want this element
            <td>
        </tr>
    </tbody>
</table>



No errors, just nothing happens.The problem I am having is stringing together to two selectors correctly. I know there is a correct syntax for doing this.

Thanks

1 Ответ

0 голосов
/ 20 сентября 2019
<style>
   .className:first-of-type  tr:first-child td:first-child
   {
     background:red;
   }
</style>

<table class="className">
    <tbody>
        <tr>
            <td>  Need to apply style to this element only
            <td>
            <td> 
              There is no style on this element
            <td>
        </tr>
    </tbody>
</table>
<table class="className">
    <tbody>
        <tr>
            <td>  Don't want this element
            <td>
        </tr>
    </tbody>
</table>
...