A hover/highlight effect meant to trigger when a visitor landed on a page section via an anchor link didn’t work. Console logging confirmed the JavaScript was finding the right elements and adding a CSS class to them exactly as intended — the class itself just had no matching style rule anywhere.
A Highlight Effect Failed Because the JS and CSS Were Never Actually Connected
⚡ Quick Fix (TL;DR)
The Culprit: The JS added one class name; the CSS only ever defined a rule for a different selector, left over from an earlier, abandoned pure-CSS attempt at the same feature. Two independently reasonable-looking approaches were stacked without either side being updated to match the other.
The Fix: Once traced, the feature was removed rather than patched further, since it wasn't earning its complexity. General lesson: when debugging "my JS runs but nothing visibly changes," check whether the class name it adds and the class name any CSS rule targets are literally identical — not just similar.
Tagged in :