/ Published in: JavaScript

This was useful today, could be made into something with a little work.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function cssRule(selector,attribute,value,replaceAll) { if(replaceAll == null) { replaceAll = false; } var ss = document.styleSheets; var count = 0; for (var i=0; i<ss.length; i++) { var rules = ss[i].cssRules || ss[i].rules; for (var j=0; j<rules.length; j++) { if (rules[j].selectorText === selector) { rules[j].style[attribute] = value; if(replaceAll) { count++; } else { return true; } } } } return count; }
Comments
