Created
March 6, 2013 20:48
-
-
Save pjeweb/5102924 to your computer and use it in GitHub Desktop.
Dynamically add css to document
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 addCssToDocument(css) { | |
var styleElement = document.createElement('style'); | |
document.getElementsByTagName('head')[0].appendChild(styleElement); | |
var isIe = styleElement.styleSheet; | |
if (isIe) | |
styleElement.styleSheet.cssText = css; | |
else | |
styleElement.appendChild(document.createTextNode(css)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment