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);
};

More

Previous
Select the children of an element
Next
Select the text of a textarea automatically