javascript - can a style sheet obtain a class or id to dynamically change it? -


i use cors pull down pages , css. store css in style tag , append head. each time load page want wipe out css.

is there easy way this? thinking giving id or class, wasnt sure if allowed. neither of them optional attributes of under definition of class, can go on element, , figured technically element.

does know how done?

the way populating is:

var css = "....."; var $style = $("<style type='text/css' />").append(css); $("head").append($style); 

style elements elements other, , if remove element, css styles defines removed.

so if have specific style element you've added, code in question, can remove doing this:

$style.remove(); 

...since have reference in $style variable.

alternately, give specific style element want remove id or class, , use remove it:

// adding ... var css = "....."; var $style = $("<style type='text/css' />").append(css).addclass("dynamic"); $("head").append($style);  // removing later... $("style.dynamic").remove(); 

you can update text of existing element, update styles defines.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -