I'm looking to enhance my website by adding tooltip descriptions to elements based on their CSS classes.
While tooltips are usually added using the element's title
attribute, I have numerous elements with the same lengthy description and want to avoid unnecessary code repetition. Instead, I prefer defining the text separately and then somehow linking it to specific classes.
Unfortunately, based on my research, it appears that achieving this goal with just HTML and CSS is not possible, though a succinct Javascript or jQuery solution would suffice. Can anyone provide guidance on how to accomplish this?
Extra credit if the text can be combined for elements with multiple classes. :P