Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 421
wheresrhys Avatar asked Nov 20 '25 13:11

wheresrhys


1 Answers

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

like image 76
Jack Avatar answered Nov 23 '25 03:11

Jack