JSFiddle - React, Tailwind, and code Playground
by rvaldez
HTML
<div class="wysiwyg">
<textarea id="test">Hello from Stack Overflow!!</textarea>
</div>
ewwewewewe
JavaScript
if(!window.Kolich){
Kolich = {};
}
Kolich.Selector = {};
Kolich.Selector.getSelected = function(){
var t = '';
if(window.getSelection){
t = window.getSelection();
}else if(document.getSelection){
t = document.getSelection();
}else if(document.selection){
t = document.selection.createRange().text;
}
return t;
}
Kolich.Selector.mouseup = function(){
var st = Kolich.Selector.getSelected();
if(st!=''){
alert("You selected:\n"+st);
}
}
$('.wysiwyg textarea').live('select', function() {
var text = Kolich.Selector.mouseup();
console.log(text);
});