JSFiddle - React, Tailwind, and code Playground
HTML
<div ontouchstart="selectElementContents(this);">
Text to be selected on touch.
<br>Text to be selected on touch.
<br>Text to be selected on touch.
<br>Text to be selected on touch.
<br>Text to be selected on touch.
<br>Text to be selected on touch.
<br>Text to be selected on touch.
</div>
JavaScript
function selectElementContents(el) {
var sel = window.getSelection();
var range = document.createRange();
range.selectNodeContents(el);
sel.removeAllRanges();
sel.addRange(range);
}