
Untitled
By: a guest on
May 2nd, 2012 | syntax:
None | size: 0.56 KB | hits: 18 | expires: Never
How do I add CSS rules to a document fragment across IE/FF?
var newDom = document.createDocumentFragment();
newDom.appendChild(document.createElement("style"));
newDom.appendChild(document.createElement("div"));
if (newDom.childNodes[0].styleSheet){
newDom.childNodes[0].styleSheet.cssText = "div{color:red;}";
alert(newDom.childNodes[1].currentStyle.color);
}else{
newDom.childNodes[0].appendChild(document.createTextNode("div{color:red;}"));
alert(window.getComputedStyle(newDom.childNodes[1], null).color);
};
obj.style.cssText = 'something';