Created
May 15, 2014 16:13
-
-
Save jbeuckm/6e523740eb75c0c38b24 to your computer and use it in GitHub Desktop.
Insert styles into the head element with jquery
This file contains hidden or 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 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