3

Related to this question Changing CSS pseudo-element styles via JavaScript, is there any way using javascript that I can access a pseudo-element's style attributes?

Community
  • 1
  • 1
wheresrhys
  • 22,558
  • 19
  • 94
  • 162

1 Answers1

9

It depends on the browser. I don't believe IE supports this in any way, but for FireFox and Webkit browsers, you can use the following:

window.getComputedStyle(element, pseudo-selector);

For example:

window.getComputedStyle(document.body, ':before');

See: getComputedStyle

danronmoon
  • 3,814
  • 5
  • 34
  • 56
Jack
  • 9,448
  • 3
  • 29
  • 33