Skip to content
Advertisement

JS Sort Table – Sort Indicators

I’ve built this table with a sort function and now I’m also trying to set a class for the selected th so I can put some arrows with CSS, as sort indicators.

I need a way to set dynamic .asc and .desc classes to my selected th with JS somewhere on my sortTable() .. It also needs to be Pure JS.

JavaScript
JavaScript
JavaScript

Advertisement

Answer

I have edited the snipped. arrow buttons will be shown when the <th> is clicked and the icons on the other headers will be removed

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement