JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" value="Hello World">
JavaScript
$("input").select(function() {
var elem = document.activeElement
console.log(elem.value.substring(elem.selectionStart, elem.selectionEnd));
});