1var sel = document.getElementById("box1");
2var text= sel.options[sel.selectedIndex].text;
3
1function disp() {
2 var text = document.getElementById("text");
3 var t = text.value.substr(text.selectionStart, text.selectionEnd - text.selectionStart);
4 alert(t);
5}
1const getSelectedText = () => window.getSelection().toString();
2
3getSelectedText();
4