102/121

Select the text content of an element

The following function selects the text content of the ele element:

const selectText = function(ele) {
    const selection = window.getSelection();
    const range = document.createRange();
    range.selectNodeContents(node);
    selection.removeAllRanges();
    selection.addRange(range);
};

Might be useful