JSFiddle - React, Tailwind, and code Playground

HTML

<input type="button" value="Select cup" onmousedown="selectCup(); return false">
<textarea type="textarea" id="test" value="Cup of tea"></textarea>

JavaScript

function selectCup() {
    var input = document.getElementById("test");
    input.setSelectionRange(3,5); // Highlights "Cup"
    input.focus();
};