L' evento select si verifica quando è selezionato un testo in una textarea o in una textbox
$(selector).select()
$(selector).select(funzione)
<script>
function GetSelectedText() {
var selText = "";
if (window.getSelection)
{
if (document.activeElement &&
(document.activeElement.tagName.toLowerCase() == "textarea" ||
document.activeElement.tagName.toLowerCase() == "input")) {
var text = document.activeElement.value;
selText = text.substring (document.activeElement.selectionStart,
document.activeElement.selectionEnd);
}
else {
var selRange = window.getSelection();
selText = selRange.toString();
}
}
else {
if (document.selection.createRange) { // Internet Explorer
var range = document.selection.createRange();
selText = range.text;
}
}
if (selText !== "") {
return (selText);
}
}
$(document).ready(function(){
$("input").select(function(){
$("#selected").text(GetSelectedText());
});
});
</script>
<input type="text" value="Seleziona un po' di testo">
<p id="selected"></p>