The ABBR and ACRONYM tags aren’t used all that often, which is too bad because they’re valuable in making a block of jargon-heavy content more readable. Unfortunately, they aren’t very intuitive, since they require the user to hover over the word to learn the definition. Why not allow them to click the tag to display the full word? jQuery makes this trivial:
jQuery(document).ready(function() {
jQuery(document).click(function(ev) {
var target = jQuery(ev.target);
if(target.attr('tagName') == 'ABBR' || target.attr('tagName') == 'ACRONYM') {
var title = target.attr('title');
var text = target.text();
target.attr('title', text);
target.text(title);
}
});
});The code can be dropped into any jQuery-enabled environment without any setup. It supports “live” events, as well: inserting new ABBR/ACRONYM tags into the DOM tree are still caught when clicked (yay event bubbling!). The code simply swaps the title attribute and the inner text when you click on either an ABBR or ACRONYM tag. I thought about animating it, but I couldn’t think of a way to do it attractively without potentially forcing a lot of expensive page reflow operations.