What is the best way of creating dynamic style tags using js and/or jQuery?
I tried this:
var style= jQuery('<style>').text('.test{}');
This works in FF but pops an error in IE7 "Unexpected call to method or property access."
var style = document.createElement('style');
style.innerHTML='.test{}';
Gives the same error. It doesn't matter if I use innerHTML
or innerText
. The strange thing is that it shows an error before appending the style tag.
I suspect that cssText
has something to do with it, but I'm not sure how.