Last active
December 19, 2022 10:49
-
-
Save linuskmr/9582dd4dfa101971f34bceb7e28cf409 to your computer and use it in GitHub Desktop.
Clicking on an abbr opens an alert box showing its title/explanation. This is useful on mobile devices that don't show the title in a tooltip.
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
// Setup onclick handler for abbr tags. Clicking on an abbr opens an alert box | |
// showing its title/explanation. This is useful on mobile devices that don't | |
// show the title in a tooltip. | |
const abbrs = document.getElementsByTagName("abbr") | |
const titleSpans = document.querySelectorAll("span[title]") | |
for (const abbr of [...abbrs, ...titleSpans]) { | |
abbr.onclick = e => alert(`${e.target.innerText}: ${e.target.title}`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment