Skip to content

Instantly share code, notes, and snippets.

@tangorri
Created July 10, 2013 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tangorri/5970595 to your computer and use it in GitHub Desktop.
Save tangorri/5970595 to your computer and use it in GitHub Desktop.
function changecss(myclass,element,value) {
var CSSRules;
if (document.all) {
CSSRules = 'rules'
}
else if (document.getElementById) {
CSSRules = 'cssRules'
}
for (var i = 0; i < document.styleSheets[0][CSSRules].length; i++) {
if (document.styleSheets[0][CSSRules][i].selectorText == myclass) {
document.styleSheets[0][CSSRules][i].style[element] = value;
console.warn(myclass + " : " + element + " => " + value + " ok");
}
else
console.warn("css: " + myclass + " NOT FOUND!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment