Skip to content

Instantly share code, notes, and snippets.

@antcolag
Created November 16, 2018 15:52
Show Gist options
  • Save antcolag/880704b144bab46eb331814f59dcc76b to your computer and use it in GitHub Desktop.
Save antcolag/880704b144bab46eb331814f59dcc76b to your computer and use it in GitHub Desktop.
var setPseudoStyle = (function() {
document.head.appendChild(document.createElement('style'));
style = document.styleSheets[document.styleSheets.length-1];
return function setPseudoStyle(elm, pseudo, text){
var id = elm.dataset.psudoLinkToStyle
if(void 0 === id){
id = style.rules.length;
style.addRule( '[data-psudo-link-to-style="'+id+'"]:'+pseudo, '', id);
elm.dataset.psudoLinkToStyle = id;
}
style.rules[id].style = text
}
})()
@antcolag
Copy link
Author

credo funzioni così

setPseudoStyle(myElm, "before", "Hello")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment