JSFiddle - React, Tailwind, and code Playground

HTML

<div id="m2560" class="yellow">DIV1: First <span style="color:red">some red text for</span> you to select
<br>
<button id="msg2560">Reply</button>
</div>
<br>
    <div id="m2900" class="green">DIV2: <b>Second some bold</b> test text for you to select
<br>
<button id="msg2900">Reply</button>
</div>
<br>
    <div id="m3022" class="blue">DIV3: <i>Third some italic test</i> text for you to select
<br>
<button id="msg3022">Reply</button>
</div>

CSS

.yellow{background:yellow}
.green{background:lightgreeen}
.blue{background:lightblue}

JavaScript

function changeButton() {
// for now this script only checks if text is selected
    var text = "";
    if (typeof window.getSelection != "undefined") {
//? it should probably be document.GetElementById('button_id').innerHTML='Quote';
    } else if (typeof document.selection != "undefined" && document.selection.type == "Text") {
//? it should probably be document.GetElementById('button_id').innerHTML='Quote';
    }
    return text;
}   
    document.GetElementById('msg***').onclick = changeButton;