How can I get the selected text in a textarea?

javascript, jquery

Solution

Try the jquery-fieldselection plugin.

You can download it from here. There is an example too.

Problem

I'm trying to make my own WYSIWYG editor. Is there a way to get the text which has the user selected in a textarea? For example, if the user selects some word and then clicks button, how do I find out which text was selected? I'm using jQuery.

Original source

Related problems