Skip to content

Instantly share code, notes, and snippets.

@jbeuckm
Created May 15, 2014 16:13
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 jbeuckm/6e523740eb75c0c38b24 to your computer and use it in GitHub Desktop.
Save jbeuckm/6e523740eb75c0c38b24 to your computer and use it in GitHub Desktop.
Insert styles into the head element with jquery
function insertStyles(selectors, styles) {
var text = selectors.join(', ') + ' { ';
for (var i in styles) {
text += i + ':' + styles[i] + '; ';
}
text += '}';
console.log(text);
var style = $('<style>'+text+'</style>');
style.appendTo("head");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment