I have the following CSS
h1:before {
content: \"Chapter \" counter(lvl1) \"\\000d\\000a\";
counter-increment:
Use getComputedStyle()
:
$('h1').each(function(){
console.log(window.getComputedStyle(this,':before').content);
});
before()
is a jQuery method used to traverse the DOM, it gets/sets the preceding element, it does not access the pseudo-element.
Working JS Fiddle, supplied by Eric.
Though there is the unfortunate caveat that this approach returns the literal string used in the content
declaration, rather than the actual generated-content.