I\'m trying to set a class to active depending on the url. I\'m trying to use the code below, but in every case, it activates the active class for the second tab.
<
You're using = instead of ==, a common programming error. = is assignment, == is comparison.
if (pathname == '/lean/subsection2') { // ...
When using =, it assigns the string /lean/subsection2 to the variable pathname and evaluates it as a boolean value, which is always true (it'd have to be false or undefined), so it always takes the positive condition block.