Skip to content

Instantly share code, notes, and snippets.

@minodisk
Created May 10, 2011 09:49
Show Gist options
  • Save minodisk/964198 to your computer and use it in GitHub Desktop.
Save minodisk/964198 to your computer and use it in GitHub Desktop.
Add style with JavaScript.
var style = document.createElement('style');
style.appendChild(document.createTextNode('#sample { background-color: #FF0000; }'));
document.documentElement.appendChild(style);
window.addEventListener('DOMContentLoaded', function () {
document.head.appendChild(style);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment