Answers for "how to define which text was selected on input element js"

0

get selected text input javascript

function disp() {
  var text = document.getElementById("text");
  var t = text.value.substr(text.selectionStart, text.selectionEnd - text.selectionStart);
  alert(t);
}
Posted by: Guest on April-20-2021
0

get text selection javascript

function getSelectionText() {
    var text = "";
    if (window.getSelection) {
        text = window.getSelection().toString();
    } else if (document.selection && document.selection.type != "Control") {
        text = document.selection.createRange().text;
    }
    return text;
}
Posted by: Guest on January-02-2022

Code answers related to "how to define which text was selected on input element js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language