0

I have created styles tag dynamically using javascript. Then create styles and assign to style object innerHTML dynamically. But it doesn't work in IE8 browser

JS fiddle: https://jsfiddle.net/erd3hbj8/

var style = document.createElement('style');
 style.type = 'text/css';
 style.innerHTML = ".myStyle{background-color: red;}";
 document.getElementsByTagName('head')[0].appendChild(style);

Anyone help on this.

Thanks, Bharathi

Kira
  • 1,403
  • 1
  • 17
  • 46
Bharathi
  • 1,288
  • 2
  • 14
  • 40
  • there is different attribute, not innerHTML – YOU Jul 05 '16 at 10:45
  • 1
    it relates to this question, http://stackoverflow.com/questions/30099441/how-to-dynamically-create-css-class-in-ie8?noredirect=1#comment48311098_30099441 can you please check this – Akbar Basha Jul 05 '16 at 10:48
  • This is not the correct way to add stylesheets to a page. – Simba Jul 05 '16 at 12:12

0 Answers0