Last active
          August 29, 2015 14:26 
        
      - 
      
- 
        Save jamenlyndon/6fc833a59c981bff7678 to your computer and use it in GitHub Desktop. 
    Modify global CSS with JS
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function css(selector, property, value) { | |
| for (var i=0; i<document.styleSheets.length;i++) { | |
| try { document.styleSheets[i].insertRule(selector+ ' {'+property+':'+value+'}', document.styleSheets[i].cssRules.length); | |
| } catch(err) {try { document.styleSheets[i].addRule(selector, property+':'+value);} catch(err) {}}//IE | |
| } | |
| } | |
| // Example usage: | |
| css('.header', 'border', '5px solid green'); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment