Add class to element on specific URL

I have some filter buttons to filter some items.

<a href="?filter=category#anker">

When you click on a filter button I want it to have an active class. So if no filter is set and the URL is / or ?filter= I want to have an active class on one filter. Or if the URL was ?filter=category put the active class on another single button.

There might be a different solution than checking if URL = something. Every solution is fine :slight_smile:

Thanks in advance!

Similar to here: Add active class on 'show all' filter list - #3 by yanickvw

Only you use your filters instead of params.