Say you have a CSS 2.1 counter like
ol { counter-reset: section; list-style-type: none; } li:before { counter-increment: section; content: counters(section, '.') ' '; } <ol> <li>itemA</li> <!-- 1 --> <li>itemB <!-- 2 --> <ol> <li>itemC</li> <!-- 2.1 --> <li id='foo'>itemD</li> <!-- 2.2 -->
(see https://developer.mozilla.org/en/CSS_Counters ‘nesting counters’)
Is there a way to read/get the :before.content (‘2.2’ in this case) for <li id='foo'> in JavaScript?
Edit: In my case a Mozilla-only solution would suffice. But there really seems to be no way to access this information. At least I didn’t find any at https://developer.mozilla.org/en/CSS_Counters ff.
None that I can think of, no. :before pseudo-elements are not part of the DOM so there is no way to address their content.
You could make a function that scanned the stylesheet’s DOM for the :before rules and worked out which rules the browser had applied where, but it would be incredibly messy.