Skip to content

Instantly share code, notes, and snippets.

@qodesmith
Last active February 2, 2016 14:45
Show Gist options
  • Save qodesmith/5f2c4fae0ed777f74ea0 to your computer and use it in GitHub Desktop.
Save qodesmith/5f2c4fae0ed777f74ea0 to your computer and use it in GitHub Desktop.
Function for styling pseudo elements with JavaScript
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