Как выбрать только первый и последний <th>? Моя таблица имеет id="mytable". Я пытаюсь применить CSS только к первой и последней <th>. Я пробовал это, но он не работает. #mytable th:first, #mytable th:last{ //css goes here } Ответ 1 #mytable th:last-child, #mytable th:first-child { //css goes here } Ответ 2 Для CSS #myTable thead tr th:first, #myTable thead tr th:last{ /*CSS goes here*/ } Использование JQuery (только для последнего дочернего): $("#mytable th:last-child").css({ /*CSS goes here*/ });
Ответ 2 Для CSS #myTable thead tr th:first, #myTable thead tr th:last{ /*CSS goes here*/ } Использование JQuery (только для последнего дочернего): $("#mytable th:last-child").css({ /*CSS goes here*/ });