I have a counter in a psuedo class in my CSS, something like this,
h2::before {
counter-increment: section;
content: "Section " counter(section) ": ";
}
and I want the computed value of counter.
I have tried using
getComputedStyles(document.getElementById("1"), '::before')
but that returns Section " counter(section) ":
, whereas I am trying to get the actual value that it displays. which is Section 1:
This is the demo HTML snippet that I have been testing with,
body {
counter-reset: section;
}
h2::before {
counter-increment: section;
content: "Section " counter(section) ": ";
}
<h2 id="1">HTML Tutorial</h2>