Answers for "js get current text selection"

5

get selected text js

// Get highlighted text this way:

window.getSelection().toString()
Posted by: Guest on April-08-2020
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 "Javascript"

Browse Popular Code Answers by Language