Skip to content

Instantly share code, notes, and snippets.

@roshanca
Created October 10, 2014 09:52
Show Gist options
  • Select an option

  • Save roshanca/615cb8c9532ac31bdf63 to your computer and use it in GitHub Desktop.

Select an option

Save roshanca/615cb8c9532ac31bdf63 to your computer and use it in GitHub Desktop.
Get pseudo-element property with javascript
// Get the color value of .element:before
var color = window.getComputedStyle(
document.querySelector('.element'), ':before'
).getPropertyValue('color');
// Get the content value of .element:before
var content = window.getComputedStyle(
document.querySelector('.element'), ':before'
).getPropertyValue('content');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment