JSFiddle - React, Tailwind, and code Playground

HTML

<p><button id="upper">UPPER CASE</button></p>
<textarea id="textarea">Highlight some of this text and click the button to make it upper case... right?</textarea>

CSS

#textarea {
    width: 350px
}

JavaScript

$(document).ready(function() {
    $("#textarea").select(function() {
        var selection = window.getSelection();
        $("#upper").click(function() {
            // alert(selection);
            var upper = selection.toUpperCase();
            var text = $("#textarea").text();
            $("#textarea").html(text.replace(selection, upper));
        });
    }); 
});