wheresrhys
wheresrhys

Reputation: 23500

Getting pseudo-element style values

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?

Upvotes: 3

Views: 3470

Answers (1)

Jack
Jack

Reputation: 9548

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

Upvotes: 9

Related Questions