Skip to content

Instantly share code, notes, and snippets.

@bitboxx
Last active December 14, 2015 06:58
Show Gist options
  • Save bitboxx/5046552 to your computer and use it in GitHub Desktop.
Save bitboxx/5046552 to your computer and use it in GitHub Desktop.
Javascript: dynamically adding CSS in to document
function loadCSS(css) {
var styleElement = document.createElement("style");
styleElement.type = "text/css";
if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = css;
} else {
styleElement.appendChild(document.createTextNode(css));
}
document.getElementsByTagName("head")[0].appendChild(styleElement);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment