I have a setup. I create a <div> , append the term "do" through the :before pseudo- getComputedStyle and read this value using getComputedStyle .
This works, I get the term (which in my case is "before") successfully, it is of type "string". (See Console Output.)
Comparison of this line with the given line returns the expected true , but only in Safari, CodePen and here, in the "Run a code fragment" -Environment!
It does NOT work in Chrome, Firefox or IE. A match comparison returns false .
What could be the reason?
Why doesn't this simple string comparison work?
The three corresponding code fragments are as follows:
var content = window.getComputedStyle(document.querySelector('.pseudo'), '::before').getPropertyValue('content'); console.log('content: ' + content);
div.pseudo:before { content: "before"; color: red; }
<div class="pseudo"> Div with pseudo :before content. </div>
source share