You mean text selection with the mouse, so here, DEMO http://jsfiddle.net/yeyene/GYuBv/2/
$('#showSelected').on('click', function(){ var text = ""; if (window.getSelection) { text = window.getSelection().toString(); } else if (document.selection && document.selection.type != "Control") { text = document.selection.createRange().text; } alert(text); });
If you want to make some changes around the selected text, check out this DEMO http://jsfiddle.net/yeyene/GYuBv/3/
source share