In the world of web development, a pseudo element like ::before
or ::after
may seem invisible in the DOM tree. It's a tricky situation because you can't just target it using a selector.
So, how do you retrieve the content within a pseudo element? Let's consider this scenario:
<div>This is <span></span>n apple.</div>
...
span::before {
content : "a"
}
Result: This is an apple.
If you try to extract the text from the div
, you'll only capture This is n apple.
without the added content from span::before
.
What's the best way to tackle this challenge?