Created
February 2, 2015 17:34
-
-
Save joews/ac8a29d6a5174c836f91 to your computer and use it in GitHub Desktop.
Get content string for a Font Awesome class (stylesheet known)
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
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