Is there any alternative method for the following code in jquery or 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;
}
}
<input id="text_selected" type="text" value="Select Text" />
<input onmousedown="console.log(isTextSelected(document.getElementById('text_selected')));" type="button" value="Selected or Not" />