I am trying to figure out why pseudo element can not be accessible by javascript. Some people says it is because pseudo element is not part of dom. Is it true? Then why we are able to access it's style properties.
var color = window.getComputedStyle(
document.querySelector('.element'), ':before'
).getPropertyValue('color')
For the given html element.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>EPS</title>
<script>
function test(){
debugger;
var a = document.getElementById("1");
var node = a.previousSibling;
}
</script>
<style>
body{
counter-reset: test;
}
ul{
list-style-type: none;
}
li::before{
counter-increment: test;
content: counter(test,lower-greek)" ";
}
</style>
</head>
<body onload="test();">
<ul>
<li id="1">do outstanding teachers do. new text added?</li>
<li id= "2">What do they do differently from you new text added ?</li>
</ul>
</body>
</html>
document.getElementById("1"); gives us an HtmlLielement which is derived from HtmlElement --> Element --> Node Is pseudo element is not inheriting from above classes hierarchy due to that i am not able to access the counter value of pseudo element before list-item 2.
Can someone give me reasons of pseudo element is not accessible from JavaScript.