I want to remove class "sorting"
from the last <th>
element of given datatable table.
<th class="sorting" tabindex="0" aria-controls="GetLibraryTable" rowspan="1" colspan="1" style="width: 108.009px;" aria-label="Action: activate to sort column ascending">Action</th>
I tried with below code:
document.querySelector("#GetLibraryTable_wrapper > div.dataTables_scroll > div.dataTables_scrollHead > div > table > thead > tr > th:nth-child(7)").removeClass('sorting');
But this gives below console error:
Uncaught TypeError: document.querySelector(…).removeClass is not a function
3
Answers
the jQuery solution is:
no jQuery plain Javascript:
for better selector use :last-of-type
To achieve your requirement, you can try this code snippet using
:last-child
selector:More information about css selectors, can refer this doc: https://www.w3schools.com/cssref/css_selectors.asp