JSFiddle - React, Tailwind, and code Playground
by Taleeb Anwar
HTML
<div>Here is some text</div>
JavaScript
$('div').mouseup(function () {
setTimeout(function () {
var txt = getSelectedText();
if(txt!=''){
alert(txt);
}
}, 3000);
});
function getSelectedText() {
if (window.getSelection) {
return window.getSelection().toString();
} else if (document.selection) {
return document.selection.createRange().text;
}
return '';
}