Last active
February 2, 2016 14:45
-
-
Save qodesmith/5f2c4fae0ed777f74ea0 to your computer and use it in GitHub Desktop.
Function for styling pseudo elements with JavaScript
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 pseudo(el, css) { | |
var string = ''; | |
for(var i in css) { | |
string += i | |
+ ':' | |
+ css[i] | |
+ ';'; | |
} | |
document.styleSheets[0].addRule(el, string); | |
} | |
// Usage: | |
// pseudo('.some-class:after', { | |
// color: 'blue', | |
// background: 'red', | |
// width: '300px' | |
// }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment