Why is not working .select() outside of the textarea, although the specifications should be?

Here.
jsfiddle.net/kukaew/ywqom126

In textarea works, but simply ignores the text. Why?

That's what people write: jquery.page2page.ru
Note that the function selectedText() will work not only for textarea and input type="text", it will return the selected text in whatever component (s) he was not.


Thank you.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script type="text/javascript">

function selectedText()
{
 if(window.getSelection) txt = window.getSelection().toString();
 else if(document.getSelection) txt = document.getSelection(); 
 else if(document.selection) txt = document.selection.createRange().text; 
 return txt;
}

$(function (){
$(document).on('select', function(){
 var seltxt = selectedText(); 
alert(seltxt);
});
});
</script>

The work of Aristotle was less in demand than a practical guide (al-Greek. τέχναι, their authors were called "technography") for speakers. The first such leadership belongs Anaximene Lensectomy (about 340 BC). 
After the Macedonian conquest disappeared political eloquence demosthenous type, declined judicial oratory, but rhetoric flourished in schools where regular exercise was the composition of speeches for fictitious court cases.<textarea>the Work of Aristotle</textarea>
July 9th 19 at 11:17
1 answer
July 9th 19 at 11:19
The question is closed. The function works, but the event select not working outside textarea. Need for "mouseup" execute instead of select. Thank you.

Find more questions by tags jQuery