How to fake highlight selection in textarea after losing focus [duplicate]

I want to put a fake highlight on selected text in a textarea after the textarea loses focus. I have explored a few options. The cleanest so far is cloning the textarea to div and wrapping selection with span. But that still has some quirks and doesn’t handle some edge cases. I have also tested a couple of jQuery libraries like this, but not as clean as I want. Is there any other clean way?