JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" ng-model="name" placeholder="Enter Name">
CSS
input {
padding: 10px;
}
JavaScript
function getSelectionHtml() {
var input = document.getElementsByTagName('input')[0];
var selectedText = input.value.substring(input.selectionStart, input.selectionEnd);
if (selectedText) {
alert(selectedText);
}
}
document.getElementsByTagName('input')[0].onmouseup = getSelectionHtml;