Last active
December 1, 2021 18:21
-
-
Save seezee/8d622da451cb856e4f110272a705d355 to your computer and use it in GitHub Desktop.
Disabled WordPress Navigation Links
Refactored the code from jQuery to vanilla JS (ES6).
Wrap code in functions. Fix bug where links that weren't direct children were also prevented from their default behavior. Target both the link and the span inside of the link.
Commented out matches.removeAttribute('href');
for keyboard accessibility.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Disable "placeholder" links in WordPress navigation, while keeping semantics and ensuring accessibility. See this essay for background on the accessibility issues.
See this Pen for a working demonstration (vanilla JavaScript and jQuery).
Add the class .nolink to "container" menu items in Appearance > Menus.
You'll also want to style the cursor like this: