I need to create a CSS stylesheet class dynamically using JavaScript in IE8.
I have used following code for other browsers:
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '.cssClass { color: #F00; }';
document.getElementsByTagName('head')[0].appendChild(style);
it's working fine in all browsers except IE8. How to achieve the same in IE8?
According to MSDN:
So, try to use
innerText
to write these class.Updated:
You can use:
Or do a test:
Hope, it now runs! :)