Can I get highlighted text with JQuery? [duplicate]
You mean text selection with mouse, so check 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 do some changes around selected text, check this DEMO http://jsfiddle.net/yeyene/GYuBv/3/