Skip to content

Instantly share code, notes, and snippets.

@danielpox
Created February 20, 2022 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielpox/423214e83ec214f602dbd091a412e0d3 to your computer and use it in GitHub Desktop.
Save danielpox/423214e83ec214f602dbd091a412e0d3 to your computer and use it in GitHub Desktop.
Append image alt text as paragraph after image
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