Problem:
- Whenever user clicks on column's header in table, a classname
.activefrom all the sametable tr th span.sortingshoud have been removed. - Add a classname
.activeto the child of currently clicked target element.
Structure:
<table>
<tr>
<th>
<span class="sorting"></span>
</th>
<th>
<span class="sorting"></span>
</th>
<th>
<span class="sorting active"></span>
</th>
</tr>
</table>
Solution (already done):
- don't know
- To add a class to a child of clicked column:
trigger.target.children[0].classList.add('active')
What is the best way to remove all active classes from <span class="sorting"> whenever I click on the <th> element and assign an active class to currently clicked block?
No jQuery, please.