JSFiddle - React, Tailwind, and code Playground
by flek
HTML
<input type="text" id="text-box" size="20" value="Mozilla">
<button onclick="selectText()">Select text</button>
JavaScript
function selectText() {
const input = document.getElementById('text-box');
input.focus();
input.setSelectionRange(2, 2);
}