Usted can agregue las reglas antes de agregar el elemento de estilo al documento.
Un par notas-
navegadores más antiguos es decir, no se puede añadir nodos secundarios de un elemento de estilo, por lo que asignar a styleSheet.csstext la propiedad del elemento para ellos. Asegúrese de agregar el nuevo elemento al encabezado del documento.
function addStyle(css, media1, title1){
var el= document.createElement('style');
el.type= 'text/css';
if(media1) el.media= media1;
if(title1) el.title= title1;
if(el.styleSheet) el.styleSheet.cssText= css;//IE
else{
el.appendChild(document.createTextNode(css));
}
//return el without the next line if you want to append it later
return document.getElementsByTagName('head')[0].appendChild(el);
}
var cs1= [
'#yw_psq, #yw_psq h2{background-color: green; color: white;}',
'#yw_psq_div{margin: 1ex; position: relative; text-align: center;}',
'#ps_counter{color: white; margin: 1ex 0 0 0; text-align: center;}',
'#pzsq_grid button{cursor: pointer; font-size: 1.2em; width: 100%;}',
'#delaySpan{font-weight: bold; margin-left: 1em;}'
]
addStyle(cs1.join('\n'),'screen','yw_psq');
Aquí tienes la respuesta: [http://stackoverflow.com/questions/524696/how-to-create-a-style-tag-with-javascript][1] [ 1]: http://stackoverflow.com/questions/524696/how-to-create-a-style-tag-with-javascript – netadictos
gracias netadictos, pero el tema es ligeramente diferente –
Creo que puede clonar el documento eliminar el hojas de estilo del clon y agregue el nuevo, obtenga el objeto y elimine el clon del documento nuevamente. – noob