JSFiddle - React, Tailwind, and code Playground

by mfittko

HTML

<div id="foo"></div>

CSS

#foo:after {
    /* access this rule from JS */
    content: "hello world";
    display: none;
}

JavaScript

var div = document.getElementById('foo'),
    content = window
        // https://developer.mozilla.org/en/DOM/window.getComputedStyle
        .getComputedStyle(div,':after')
        // https://developer.mozilla.org/en/DOM/CSSStyleDeclaration
        .getPropertyValue('content');
// IE<9 don't support getComputedStyle()
// http://msdn.microsoft.com/en-us/library/ms536497.aspx

alert(content);

// http://adactio.com/journal/5429/