Reputation: 7056
think this should be an easy one... I want to get the currently selected text using jquery's select() function.
$('textarea').select(function(selection) {
alert(selection);
});
This returns [object Object]... how do I return the selected text?
Many thanks
Upvotes: 1
Views: 463
Reputation: 30135
From jquery's select() doc:
The method for retrieving the current selected text differs from one browser to another. A number of jQuery plug-ins offer cross-platform solutions.
a quick google search for "jquery get selected text" turned up this:
http://motyar.blogspot.com/2010/02/get-user-selected-text-with-jquery-and.html
this:
http://mark.koli.ch/2009/09/use-javascript-and-jquery-to-get-user-selected-text.html
and many more
Upvotes: 4