Skip to content

Instantly share code, notes, and snippets.

@joews
Created February 2, 2015 17:34
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 joews/ac8a29d6a5174c836f91 to your computer and use it in GitHub Desktop.
Save joews/ac8a29d6a5174c836f91 to your computer and use it in GitHub Desktop.
Get content string for a Font Awesome class (stylesheet known)
function getContent(faClass) {
var styleSheet = document.styleSheets[1];
var selector = '.' + faClass;
var rules = [].filter.call(styleSheet.rules, function(rule) {
return rule.selectorText && (rule.selectorText.split('::')[0] === selector)
});
if(rules.length > 0) {
return rules[0].style.content
} else {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment