Skip to content

Instantly share code, notes, and snippets.

@NathalieLarsson
Created December 4, 2013 08:04
Show Gist options
  • Save NathalieLarsson/7783839 to your computer and use it in GitHub Desktop.
Save NathalieLarsson/7783839 to your computer and use it in GitHub Desktop.
// Source: http://jsfiddle.net/hMEHB/15/
$(document).ready(function () {
'use strict';
var descenders = {"g": true, "j": true, "p": true, "q": true, "y": true};
$('a').each(function (i, elem) {
var self = $(elem),
textNodes = self.text().split(''),
i = 0;
for (i = 0; i < textNodes.length; i += 1) {
if (descenders[textNodes[i]]) {
textNodes[i] = '<span class="descender">' + textNodes[i] + '</span>';
} else {
textNodes[i] = '<span class="underline">' + textNodes[i] + '</span>';
}
}
self.html(textNodes.join(''));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment