Select the text of a textarea automatically

Assume that ele represents a textarea element.
ele.addEventListener('focus', function (e) {
// Select the text
e.target.select();
});

See also