Skip to content

Instantly share code, notes, and snippets.

@travismillerweb
Created February 18, 2014 21:40
Show Gist options
  • Save travismillerweb/9080805 to your computer and use it in GitHub Desktop.
Save travismillerweb/9080805 to your computer and use it in GitHub Desktop.
JS - Style Before and After Elements
/*
JS - Style Before and After Elements
Reference Site: http://davidwalsh.name/ways-css-javascript-interact
*/
// 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