// Get highlighted text this way:
window.getSelection().toString()
function disp() {
var text = document.getElementById("text");
var t = text.value.substr(text.selectionStart, text.selectionEnd - text.selectionStart);
alert(t);
}
const getSelectedText = () => window.getSelection().toString();
getSelectedText();