JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<style>
p { color:blue; }
div { color:red; }
</style>
</head>
<body>
<p>
Click and drag the mouse to select text in the inputs.
</p>
<input type="text" id='selectTxt' value="Some text" />
<input type="text" value="to test on" />
<p></p>
<div id="output"></div>
</body>
</html>
JavaScript
$("#selectTxt").select( function (e) {
alert("You selected: "+window.getSelection());
$("#output").text(window.getSelection()).show().fadeOut(1000);
});