Created
February 20, 2022 15:32
-
-
Save danielpox/423214e83ec214f602dbd091a412e0d3 to your computer and use it in GitHub Desktop.
Append image alt text as paragraph after image
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
document.querySelectorAll('img[alt]:not([alt=""])') | |
.forEach(img => { | |
const alt = document.createElement('p') | |
alt.innerText = img.getAttribute('alt') | |
alt.className = 'image-alt-text' | |
img.after(alt) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment