Last active
August 1, 2023 08:09
-
-
Save jmcamposdev/e12bc47fd2d47a3484a13b139e36ea8d to your computer and use it in GitHub Desktop.
Solved WAVE (Empty Links)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('load', () => { | |
const anchors = document.querySelectorAll('a'); | |
anchors.forEach(anchor => { // Iterate all the anchors | |
if (anchor.textContent.trim() == "") { // If the anchor is empty add the arial-label | |
anchor.setAttribute('aria-label', 'Go to ' + anchor.href) | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wordpress
Using this snippet you can solve the WAVE problem of Empty Links.
Add this code to your footer and will be load in all pages
Is create to WAVE Accessibility --> https://wave.webaim.org/