JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="test" value="Some text">
<input type="button" onmousedown="alert(isTextSelected(document.getElementById('test')));" value="Selected?">

JavaScript

function isTextSelected(input) {
    if (typeof input.selectionStart == "number") {
        return input.selectionStart == 0 && input.selectionEnd == input.value.length;
    } else if (typeof document.selection != "undefined") {
        input.focus();
        return document.selection.createRange().text == input.value;
    }
}