JSFiddle - React, Tailwind, and code Playground

HTML

<title>onselect test</title>

<body>
<textarea class="text1" cols="30" rows="3">
Highlight some of this text
with the mouse pointer
to fire the onselect event.
</textarea>
</body>

CSS

.text1 { border: 2px solid red; }

JavaScript

window.onselect = selectText;
function selectText()
{
 alert("select event detected!");
}