JSFiddle - React, Tailwind, and code Playground

HTML

<p id="pText">here is some text</p>

JavaScript

document.getElementById('pText').onmouseup = function(){
    var sel = window.getSelection(), range;
    if (sel.getRangeAt) {
        range = sel.getRangeAt(0);
            alert(range);
    }
};