4

https://jsfiddle.net/2gf6gq0s/

I use ::after pseudo-element to insert text in my document:

<div class="foo"></div>
<div>test</div>

<style>
.foo::after { content: "hello johnny"; }
</style>

However, if I press Ctrl+F to find a text, I would not be able to find a word "hello" or word "johnny". Obviously, with the word "test" is all okay.

How it may be fixed?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
john c. j.
  • 725
  • 5
  • 28
  • 81
  • 1
    You can't. This is the browser's behaviour. File a bug report (or feature request). – GolezTrol May 06 '16 at 09:26
  • As a workaround, you can run a bit of JavaScript after loading that collects all before and after contents, and copies those contents in hidden spans in the elements. This would enable the user to find the texts; it wouldn't actually highlight the texts when found though. – Mr Lister May 06 '16 at 10:05
  • By the way, I think [this](http://stackoverflow.com/q/19646061/1016716) is a much better candidate for the original question than the one it was now closed as a duplicate of. It actually provides a partial solution! – Mr Lister May 06 '16 at 10:07

1 Answers1

0

It's not possible (unless browser itself has this functionality) because pseudo element are not in DOM. So even with js/jQuery you can't select them

Justinas
  • 41,402
  • 5
  • 66
  • 96